Asp.Net URL 处理

发布于 2024-07-15 06:14:59 字数 158 浏览 7 评论 0原文

是否有内置方法来处理像 Def​​ault.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

じее 2024-07-22 06:15:00

您可以编写 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.

ζ澈沫 2024-07-22 06:15:00

查看 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...

沫离伤花 2024-07-22 06:15:00

如果您希望您的应用程序执行“友好网址”,那么您肯定希望避免“.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.

錯遇了你 2024-07-22 06:15:00

您可以使用 Request.Url.Segments 数组解析附加的“文件夹”:

this.Response.Write(this.Request.Url.Segments[this.Request.Url.Segments.Length - 1]);

然后使用 Server.Transfer 或呈现您喜欢的任何内容。 您经常会遇到 CSS 等相对路径等问题。

You can parse out the appended "folder" using the Request.Url.Segments Array:

this.Response.Write(this.Request.Url.Segments[this.Request.Url.Segments.Length - 1]);

Then use Server.Transfer or render whatever you like. You will often have problems with relative paths and such for CSS and the like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文