asp.net get query string value after url rewriting
<p>I using iis url rewriting,
I added this rule</p>

<pre><code>&lt;rule name="rewrite to details pages" stopProcessing="true"&gt;
    &lt;match url="^details/([0-9]+)" /&gt;
    &lt;action type="Rewrite" url="pages/details.aspx?id={R:1}" /&gt;
&lt;/rule&gt;
</code></pre>

<p>to rewrite this url :</p>

<blockquote>
  <p>/pages/details.aspx?id=12</p>
</blockquote>

<p>to </p>

<blockquote>
  <p>/details/12</p>
</blockquote>

<p>so, after requesting new url : /details/12, and try to get query string using this code :</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        long itemid;
        if (long.TryParse(Request.QueryString["id"], out itemid))
        {
           // value is null
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }
    catch
    {
        Response.Redirect("default.aspx");
    }
}
</code></pre>

<p>i cant get any value</p>

<p>and i also tried :</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //var rawURl = Request.RawUrl;
            //Uri currentUrl = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + Request.ServerVariables["SCRIPT_NAME"] + "?" + Request.ServerVariables["QUERY_STRING"]);

            Uri theRealURL = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl);
            string yourValue = HttpUtility.ParseQueryString(theRealURL.Query).Get("id"); 

            long itemid;
            if (yourValue , out itemid))
            {
               // no query strings
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        catch
        {
            Response.Redirect("default.aspx");
        }
    }
</code></pre>

<p>but theRealURL comes without any query strings !!
Debugging result:</p>

<blockquote>
  <p>{<a href="http://localhost:46476/pages/details.aspx" rel="nofollow">http://localhost:46476/pages/details.aspx</a>}</p>
</blockquote>

<p>so how can i get query string after rewrite url ?</p>