1

I have an existing Asp.net 4.0 web form application which has used Asp.net routing 4.0. Now, I have to add a route to my web form application. But i cant figure out how to access the querystring to my aspx page.

What i did is,

routes.MapPageRoute("Products","Products/","~/WebPages/Products.aspx?pid=4",false)

After adding that piece of code what i expected was that, when i browse http:\localhost\mysite\Products i should be redirected to my Products.aspx page and there I should be able to access the Request.QueryString["pid"]. But I am not able to access the querystring.

I doubt whether this is allowed in Asp.net 4.0 Routing for Webforms. How can i fulfill my requirement?

Thanks, M

1 Answer 1

2

Something like:

 routes.MapPageRoute("ProductssRoute",
    "Products/{*queryvalues}", "~/Products.aspx",
    false,
    new RouteValueDictionary 
        { { "pid", @"\d{4}" }});

See http://msdn.microsoft.com/en-us/library/cc668177.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

this will work only if when i browse http:\\localhost\Products\2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.