ASP.NET 路由
我有一项小任务要做,我想从这里开始比做错事然后再来这里要好。 我需要将 URL 替换为更友好的格式,如下所示: 当前:www.MySite.com/default.aspx?userID=XX 我希望用户输入:www.MySite.com/user/(UserName)
另外,当前:www.MySite.com/default.aspx?userID=XX&ref#XX 我希望用户输入:www.MySite.com/user/(UserName)/ref#{refno}
提前致谢
PS:我不想使用 Asp.net MVC。
I have a small task to do, and figured it would be better to start here than doing it wrong then coming here again.
I need to replace my URLs with a more friendly format as the following:
Current: www.MySite.com/default.aspx?userID=XX
I want it the users to type : www.MySite.com/user/(UserName)
Also, Current: www.MySite.com/default.aspx?userID=XX&ref#XX
I want the users to type: www.MySite.com/user/(UserName)/ref#{refno}
Thanks in advance
PS: I do not want to use Asp.net MVC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在不使用 MVC 的情况下使用 MVC 路由功能,因为它是构建在 ASP.net 之上的单独组件。
有一篇关于 4GuysFromRolla 的 文章 关于这一点。
You can use the MVC Routing Feature without using MVC, as it's a separate component built on top of ASP.net.
There is an article on 4GuysFromRolla about this.
您可以在 Webforms 中使用路由:
在不使用 ASP.NET MVC 的情况下使用 ASP.NET 路由
You can use routing in Webforms:
Using ASP.NET Routing Without ASP.NET MVC
如果可以的话,我会使用 IIS7 URL 重写来实现这一点。 您的映射配置可以放入您的 web.config 中,并且您根本不必更改您的应用程序。
If you can, I'd just use IIS7 URL Rewriting for that. Your mapping configuration can go in your web.config, and you wouldn't have to change your application at all.