Asp.Net URL 处理
是否有内置方法来处理像 Default.aspx/mycontent 这样的 url,还是我需要通过获取 url 并剥离文件路径来自己处理它?
我尝试过寻找它但没有找到任何东西。
我想处理 .aspx/parameters 并且不考虑 Mod/URL 重写。
Is there a built in method to handle urls like Default.aspx/mycontent or do I need to handle it myself by taking the url and stripping of the file's path?
I have tried searching for it but haven't been able to find anything.
I'd like to handle .aspx/parameters and am not looking at Mod/URL Rewrite.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以编写 url 重写处理程序,使用 Webforms 应用程序中的 ASP.NET MVC 路由,或使用ASP.NET MVC 而不是 Webform。
You could either write an url rewrite handler, use ASP.NET MVC routing in your webforms application, or use ASP.NET MVC instead of webforms.
查看 ASP.NET MVC。 这个框架显然远远超出了“用户友好”的 URL 范围,但它也将其作为副产品处理。
或者你可以写一个 HttpFilter...
Take a look at ASP.NET MVC. This framework obviously goes far beyond just "user-friendly" URLs, but it does also handle this as a byproduct.
Or you could just write a HttpFilter...
如果您希望您的应用程序执行“友好网址”,那么您肯定希望避免“.aspx”出现在网址中吗? 考虑过 ASP.NET-MVC 或至少它的路由元素。
If you want you're app to do "friendly urls" then surely you would want to avoid ".aspx" appearing in the URL? Have considered ASP.NET-MVC or at least the routing elements of it.
您可以使用 Request.Url.Segments 数组解析附加的“文件夹”:
然后使用 Server.Transfer 或呈现您喜欢的任何内容。 您经常会遇到 CSS 等相对路径等问题。
You can parse out the appended "folder" using the Request.Url.Segments Array:
Then use Server.Transfer or render whatever you like. You will often have problems with relative paths and such for CSS and the like.