ASP.NET MVC 提供的 URL

发布于 2024-07-12 13:20:51 字数 122 浏览 10 评论 0原文

有没有办法在 asp.net 中实现 URL 机制,就像在 asp.net mvc 中一样,

例如 mydomain.com/user/myusername 但不使用 MVC

如果是这样,怎么办?

Is there any way to implement a URL mechanisim in asp.net like it has in asp.net mvc

e.g. mydomain.com/user/myusername but without using the MVC

if so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

不顾 2024-07-19 13:20:51

您可以使用 System.Web.Routing 程序集来执行此操作,

这是 博客文章 显示如何:-)

You do this by using the System.Web.Routing assembly

Here's a blogpost showing how :-)

岁吢 2024-07-19 13:20:51

您可以使用 ASP.NET MVC 在 ASP.NET WebForm 应用程序内部使用的相同路由机制。 查看 Phil Haack 的帖子,了解如何操作了解更多信息。

或者

如果您不想使用路由功能并且想要自己推出,请检查此 问题出来。

You can use the same routing mechanism that ASP.NET MVC uses inside of an ASP.NET WebForm application. Check this post by Phil Haack on how to learn more about it.

or

If you don't want to use the routing feature and you want to roll your own, check this question out.

内心旳酸楚 2024-07-19 13:20:51

如果您可以访问 IIS:

  • 如果是 IIS7,则 URL 重写模块可能会起作用。
  • 将 IIS 设置为使用 ASP.NET 处理任何请求,并向 Global.ashx 添加一个条目。

如果是 Apache,请使用 mod_rewrite。

否则,您可以使用:
http://myserver/Web.aspx/url/1
或:
http://myserver/Url.aspx/1
并且处理Request.Uri.PathInfo

它必须转到某个地方的.aspx文件,否则它将不会被处理。

If you have access to IIS:

  • If it is IIS7, the URL Rewriting module might work.
  • Set IIS up to process ANY request with ASP.NET, and add an entry to Global.ashx

If it is Apache, use mod_rewrite.

Otherwise, you could use:
http://myserver/Web.aspx/url/1
or:
http://myserver/Url.aspx/1
and process Request.Uri.PathInfo

It has to go to a .aspx file somewhere, as otherwise it will not be processed.

简单爱 2024-07-19 13:20:51

我过去曾使用 ASP.NET 2.0 和 UrlRewrite.Net 库完成此

操作唯一的技巧是如果您希望它能够处理没有 aspx 扩展名的路径,则必须将 IIS 配置为通过 ASP.NET 引擎传递每个请求。

I've done this in the past with ASP.NET 2.0 and the UrlRewrite.Net library

The only trick is that if you want it to work with paths that don't have aspx extensions, you have to configure IIS to pass every request through the ASP.NET engine.

面犯桃花 2024-07-19 13:20:51

我在 2005 年左右构建了一个经典的 ASP.NET(我不敢相信这个术语存在)应用程序,它使用了重写,MSDN 上的这篇文章当时非常有帮助:http://msdn.microsoft.com/en-us/library/ms972974.aspx

如果您受限于 2.0,甚至 1.1,这可能是可行的方法,因为 System.Web.Routing 仅适用于 3.5。

I built a classic ASP.NET (I can't believe this term exists) application around 2005 that used rewriting, and this article on MSDN was very helpful at the time: http://msdn.microsoft.com/en-us/library/ms972974.aspx.

If you're constrained to 2.0, or even 1.1, this may be the way to go, as System.Web.Routing is 3.5 only.

四叶草在未来唯美盛开 2024-07-19 13:20:51

IIRF 对 IIS5 和 6 进行 URL 重写。
它支持正则表达式。 自由的。 开源。

IIRF does URL Rewrite for IIS5 and 6.
It supports Regex. Free. Open source.

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