Asp.net 4.0 路由,在 Web 表单中访问查询字符串
我有一个现有的 Asp.net 4.0 Web 表单应用程序,它使用了 Asp.net 路由 4.0。现在,我必须向我的 Web 表单应用程序添加一条路由。但我不知道如何访问我的 aspx 页面的查询字符串。
我所做的是,
routes.MapPageRoute("Products","Products/","~/WebPages/Products.aspx?pid=4",false)
添加那段代码后我期望的是, 当我浏览 http:\localhost\mysite\Products 时,我应该被重定向到我的 Products.aspx 页面,在那里我应该能够访问 Request.QueryString["pid"]。 但我无法访问查询字符串。
我怀疑 Asp.net 4.0 Webforms 路由是否允许这样做。我怎样才能满足我的要求?
谢谢, 中号
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类似于:
请参阅 http://msdn.microsoft.com/en-us/library /cc668177.aspx
Something like:
See http://msdn.microsoft.com/en-us/library/cc668177.aspx