Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use URL Re-Write with Query String
    primarykey
    data
    text
    <p>I am trying to create a URL re-write with a query string but my problem is the URL re-write does not work when I try to use the query string. The URL re-write works fine when I use it without the query sting. I have searched online and did exactly what they said but I was still getting an error. So let me show you what works first which is without the query-string:</p> <p>This is what I have in the Global.asax file:</p> <pre><code>protected void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RegisterRoutes(RouteTable.Routes); } public static void RegisterRoutes(RouteCollection routeCollection) { routeCollection.MapPageRoute("RouteForCustomer", "MyTest", "~/Users/MyOldPage.aspx"); } </code></pre> <p>Everything works fine if I run the code above. So I have tried now to pass query-string in the URL and this what I have done that does not work so far:</p> <pre><code>protected void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RegisterRoutes(RouteTable.Routes); } public static void RegisterRoutes(RouteCollection routeCollection) { routeCollection.MapPageRoute("RouteForCustomer", "MyTest/{My_ID}", "~/Users/MyOldPage.aspx"); } </code></pre> <p>And the code behind for MyOldPage.aspx I have this code but not sure if it is even necessary but this is what I saw online when I was researching:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { string myquerystring = Page.RouteData.Values["My_ID"] as string; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload