title: QueryString always returns null in webform
body: <p>I use facebook share feature to share image url and return the user back to same page if click on the image on facebook.</p>
  
  <p>I have some backend logic in place where user will be redirected to the page after some prosessing is done on ImageShare.aspx page</p>
  
  <p>Below is a sample url when sharing</p>
  
  <p><code>http://www.facebook.com/sharer/sharer.php?u=http://domain.com/ImageShare.aspx?img=f3082420-8b92-4301-b093-bf8ce3f91772.jpg&amp;slide=1&amp;lg=1&amp;pageurl=http://domain.com/photo/2016/album-images</code></p>
  
  <p>CODE</p>
  
  <pre><code>System.Text.StringBuilder sbMetaDetails = new System.Text.StringBuilder();
  string urlReferer;
  string pageURL=null;
  if (HttpContext.Current.Request.UrlReferrer != null)
  {
  pageURL = Request["pageurl"] + "#lg=1&amp;slide=" + Request["slide"];
  .....
  .....
  .....
  }
  </code></pre>
  
  <p><code>Request["pageurl"] AND Request["slide"]</code> URL always return null. I am not sure why this is happening. </p>
  
  <p>I am not able to figure out why i get null for these values <code>Request["pageurl"] AND Request["slide"]</code></p>
  
  <p>UPDATE:</p>
  
  <p>I noticed that problem doesnt seems to be querystring. when i checked the source of form it show it it show action url only with img query string
  <code>&lt;form method="post" action="./ImageShare.aspx?img=f3082420-8b92-4301-b093-bf8ce3f91772.jpg" id="form1"&gt;</code></p>
  
  <p>I am trying to pass following url to facebook <code>http://www.facebook.com/sharer/sharer.php?u=http://domain.com/ImageShare.aspx?img=f3082420-8b92-4301-b093-bf8ce3f91772.jpg&amp;slide=1&amp;lg=1&amp;pageurl=http://domain.com/photo/2016/album-images</code></p>
  
  <p>but my og:url tags are not as i want them to be. source of teh page</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;&lt;title&gt;
  
  &lt;/title&gt;&lt;meta property='og:image' content='http://www.domain.com/Images/gallery/images/f3082420-8b92-4301-b093-bf8ce3f91772.JPG'/&gt;
  &lt;meta property='og:type' content='article'/&gt;
  &lt;meta property='og:title' content='Title of the image'/&gt;
  &lt;meta property='og:description' content='Description of teh image'/&gt;
  &lt;meta property='og:url' content='#lg=1&amp;slide='/&gt;
  &lt;meta property='og:site_name' content='http://www.domain.com'/&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" action="./ImageShare.aspx?img=f3082420-8b92-4301-b093-bf8ce3f91772.jpg" id="form1"&gt;
  &lt;div class="aspNetHidden"&gt;
  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTU3MzMzMjM1OQ9kFgQCAQ9kFgICAQ8WAh4EVGV4dAXIAzxtZXRhIHByb3BlcnR5PSdvZzppbWFnZScgY29udGVudD0naHR0cDovL3d3dy5oYWJ0b29yVGVubmlzLmNvbS9JbWFnZXMvZ2FsbGVyeS9pbWFnZXMvZjMwODI0MjAtOGI5Mi00MzAxLWIwOTMtYmY4Y2UzZjkxNzcyLkpQRycvPg0KPG1ldGEgcHJvcGVydHk9J29nOnR5cGUnIGNvbnRlbnQ9J2FydGljbGUnLz4NCjxtZXRhIHByb3BlcnR5PSdvZzp0aXRsZScgY29udGVudD0nQWduZXMgQnVrdGEnLz4NCjxtZXRhIHByb3BlcnR5PSdvZzpkZXNjcmlwdGlvbicgY29udGVudD0nQWduZXMgQnVrdGEgb2YgSHVuZ2FyeSBkdXJpbmcgaGVyIDFzdCByb3VuZCBxdWFsaWZ5aW5nIG1hdGNoJy8+DQo8bWV0YSBwcm9wZXJ0eT0nb2c6dXJsJyBjb250ZW50PScjbGc9MSZzbGlkZT0nLz4NCjxtZXRhIHByb3BlcnR5PSdvZzpzaXRlX25hbWUnIGNvbnRlbnQ9J2h0dHA6Ly93d3cuaGFidG9vcnRlbm5pcy5jb20nLz4NCmQCAw9kFgICAQ8PFgIeCEltYWdlVXJsBVtodHRwOi8vd3d3LmhhYnRvb3JUZW5uaXMuY29tL0ltYWdlcy9nYWxsZXJ5L2ltYWdlcy9mMzA4MjQyMC04YjkyLTQzMDEtYjA5My1iZjhjZTNmOTE3NzIuanBnZGRkDzpF0HTS6mi1GJe2v3ZqBKOICQk=" /&gt;
  &lt;/div&gt;
  
  &lt;div class="aspNetHidden"&gt;
  
      &lt;input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="1F8C24FB" /&gt;
  &lt;/div&gt;
      &lt;div&gt;
  
      &lt;/div&gt;
          &lt;img id="ImgName" src="http://www.domain.com/Images/gallery/images/f3082420-8b92-4301-b093-bf8ce3f91772.jpg" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Complete Code for the page</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data;
  using CMS.DataAccessLayer;
  using CMS.SqlHelper;
  using CMS.DateConvertion;
  using CMS.BusinessObjects;
  using CMS.DataAccessLayer;
  using System.Web.Routing;
  using System.Text.RegularExpressions;
  
  public partial class ImageShare2 : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
         showDetails();
  
      }
  
  
  
      public void showDetails()
      {
          try
          {
              DataSet ds = new DataSet();
  
  
              var img = Request["img"];
  
              if (!String.IsNullOrEmpty(img))
              {
                  String strSql = "SELECT * FROM PhotoAlbumImages WHERE PhotoImageLarge ='" + img + "'";
                  ds = DataProvider.Connect_Select(strSql);
                  DataTable dt = ds.Tables[0];
                  int rCount = ds.Tables[0].Rows.Count;
                  int ctr = 0;
                  var Title = String.Empty;
                  string  imgURL = String.Empty;
                  ImgName.ImageUrl = "http://www.Domain.com/Images/gallery/images/" + img;
                  //ogImage.Content = "~/Images/gallery/images/" + img;
  
  
                  System.Text.StringBuilder sbMetaDetails = new System.Text.StringBuilder();
                  string urlReferer;
                  string pageURL=null;
  
                  //Response.Write("&lt;br/&gt;&lt;br/&gt;Request.UrlReferrer : " + Request.UrlReferrer +"&lt;br/&gt;");
  
                  if (HttpContext.Current.Request.UrlReferrer != null)
                  //if (HttpContext.Current.Request.UrlReferrer == null)
                  {
  
                     // urlReferer = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.ToString().ToLower();
  
                      //pageURL = Helper.GetQueryStringValue("purl");
                      //Response.Write("Helper.GetQueryStringValue('pageurl')&lt;br&gt; " + Request.QueryString["pageurl"]);
                      pageURL = Request.QueryString["pageurl"] + "#lg=1&amp;slide=" + Request.QueryString["slide"];
                      //BUILD Redirect URL
  
  
  
  
                      foreach (DataRow dr in dt.Rows)
                      {
                          Title = dr["PhotoTitle"].ToString();
  
                          imgURL = "http://www.Domain.com/Images/gallery/images/" + dr["PhotoImageLarge"].ToString();
  
                          sbMetaDetails.AppendLine("&lt;meta property='og:image' content='" + imgURL + "'/&gt;");
                          sbMetaDetails.AppendLine("&lt;meta property='og:type' content='article'/&gt;");
                          sbMetaDetails.AppendLine("&lt;meta property='og:title' content='" + Title + "'/&gt;");
                          sbMetaDetails.AppendLine("&lt;meta property='og:description' content='" + dr["PhotoDesc"].ToString() + "'/&gt;");
                          //sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + Request.Url.ToString() + "'/&gt;");
  
                          if (!string.IsNullOrEmpty(pageURL))
                          {
                              sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + pageURL + "'/&gt;");                           
                              Response.Write("AA&lt;br&gt;");
                          }
                          else
                          {
                              sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + Request.Url.ToString() + "'/&gt;");
                              Response.Write("AB&lt;br&gt;");
                          }
                          sbMetaDetails.AppendLine("&lt;meta property='og:site_name' content='http://www.Domain.com'/&gt;");
                      }
  
                      litCtrMetaForSM.Text = sbMetaDetails.ToString();
  
                      //redirect
                      //Response.Redirect(pageURL);
  
                  }
                  else
                  {
  
                      urlReferer = "";
                      foreach (DataRow dr in dt.Rows)
                      {
                          Title = dr["PhotoTitle"].ToString();
  
  
                          imgURL = "http://www.Domain.com/Images/gallery/images/" + dr["PhotoImageLarge"].ToString();
                          // ogImage.Content = imgURL;
  
                          sbMetaDetails.AppendLine("&lt;meta property='og:image' content='" + imgURL + "'/&gt;");
  
                          sbMetaDetails.AppendLine("&lt;meta property='og:type' content='article'/&gt;");
                          sbMetaDetails.AppendLine("&lt;meta property='og:title' content='" + Title + "'/&gt;");
                          sbMetaDetails.AppendLine("&lt;meta property='og:description' content='" + dr["PhotoDesc"].ToString() + "'/&gt;");
                          //sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + Request.Url.ToString() + "'/&gt;");
                          if (pageURL == null)
                          {
                              sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + Request.Url.ToString() + "'/&gt;");
                          }
                          else
                          {
                              sbMetaDetails.AppendLine("&lt;meta property='og:url' content='" + pageURL + "'/&gt;");
                          }
                          sbMetaDetails.AppendLine("&lt;meta property='og:site_name' content='http://www.Domain.com'/&gt;");
                          litCtrMetaForSM.Text = sbMetaDetails.ToString();
                          //Response.Redirect(pageURL);
                      }
                  }
  
  
  
  
  
  
  
  
              }
  
          }
          catch (Exception ex) { Response.Write(ex.Message.ToString());}
  
      }
  
  
  
  
  }
  </code></pre>
  
  <p><strong>CODE BEHIND</strong></p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageShare.aspx.cs" Inherits="ImageShare2" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;asp:Literal ID="litCtrMetaForSM" runat="server"&gt;&lt;/asp:Literal&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
  
      &lt;/div&gt;
          &lt;asp:Image ID="ImgName" runat="server" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>