开发者

Asp.net 4.0 Routing , accessing querystring in Web Forms

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜