如何使虚拟 URL 指向部署在 IIS 上的 asp.net 中的 .aspx 页面? (最好没有IIS)

发布于 2024-07-07 17:00:18 字数 719 浏览 13 评论 0原文

获得像堆栈溢出那样干净整洁的 URL 结构的最佳方法是什么?

我需要为此使用 IIS 吗? 或者有没有一种方法可以使用 asp .net 中的某种映射文件来做到这一点?

我想要的网站有数百个页面,并且已经部署。
我想要一种需要尽可能少的更改的方法。

注意:

  • 想要有关如何使 URL 变得友好的建议,但
  • 确实想要有关如何最好地管理这些友好 URL 以及如何创建映射的建议。

我基本上希望每个以 aspx 结尾的路径都没有 aspx 扩展名,而是看起来像一个内部带有 index.aspx 的文件夹。

http://www.blahblahblahblahblah7CEE53E1.com/test.aspx

->

http://www.blahblahblahblahblah7CEE53E1.com/test/

编辑:我正在运行 IIS 6.0

What's the best way to get a nice clean URL structure like stack overflow has?

Do I need to use IIS for this? Or is there a way I can do it with some sort of mapping file in asp .net?

The site I want this for has hundreds of pages, and is already deployed.
I would like a method that requires the least amount of changes possible.

Note:

  • I do not want suggestions on how to make the URLs friendly
  • I do want suggestions on how to best manage these friendly URLs and how to create the mappings.

I basically want to have each path that ends with aspx have no aspx extension and instead look like it is a folder with an index.aspx inside of it.

http://www.blahblahblahblahblah7CEE53E1.com/test.aspx

->

http://www.blahblahblahblahblah7CEE53E1.com/test/

EDIT: I'm running IIS 6.0

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

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

发布评论

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

评论(5

梦在深巷 2024-07-14 17:00:18

<system.web>
  <urlMappings enabled="true">
    <add url="~/test/" mappedUrl="~/test.aspx"/>
  </urlMappings>

也许 urlMappings 可以为你工作 在 IIS6 上工作时,您可以启用通配符映射。

Perhaps urlMappings could work for you:

<system.web>
  <urlMappings enabled="true">
    <add url="~/test/" mappedUrl="~/test.aspx"/>
  </urlMappings>

To make it work on IIS6 you to enable wildcard mappings.

俏︾媚 2024-07-14 17:00:18

据我了解,您正在寻找一种可以帮助您进行映射的工具。

如果是这种情况,您可以尝试“

规则模板用于提供一种为特定场景创建一个或多个重写规则的简单方法。 URL 重写器模块包含一些用于一些常见使用场景的规则模板。 除了 URL 重写模块之外,UI 还提供了一个用于插入自定义规则模板的框架。

from what I understand, you are looking for a tool to help you with mappings.

If that is the case, you can try the "user friendly url - rule template" feature of url rewrite module (iis7)

Rule templates are used to provide a simple way of creating one or more rewrite rules for a certain scenario. URL rewriter module includes several rule templates for some common usage scenarios. In addition to that URL rewrite module UI provides a framework for plugging in custom rule templates.

红墙和绿瓦 2024-07-14 17:00:18

Stackoverflow uses System.Web.Routing. It's originally from asp.net MVC but usable in any asp.net app. I'm not sure how easy or hard it would be to retrofit routing into an existing app though.

酒中人 2024-07-14 17:00:18

我一直在使用一个名为 Ionic Rewriter 的工具,

它将使用正则表达式将无扩展名 URL 重写为物理 URL进行加工。 用户只能看到无扩展名的文件,但网络服务器可以看到 .aspx 等文件。

它似乎工作得非常好并且非常容易配置。

I have been using a tool called Ionic Rewriter

It will use regular expression to rewrite your extensionless URLs to physical URLs for processing. The user only sees the extensionless one however the webserver sees the .aspx etc one.

It seems to work extremely well and is very easy to configure.

嘿咻 2024-07-14 17:00:18

我不知道IIS6.0是否支持它,但我使用web.sitemap,我为每个节点添加一个等于我想要的漂亮名称的属性,然后使用Application_onBegin将请求的漂亮url映射到站点地图...

您要求最好的方法,但我不认为有一种“最好”的方法,我见过人们从 xml 文件提供漂亮的名称,其他人依赖 IIS7.0 重写功能

i dont know if IIS6.0 supports it or not, but i use web.sitemap, i add an attribute with every node that equals the pretty name i want, then with Application_onBegin I map the pretty url of the request to the one in the sitemap...

you asked for the best way, but I dont think there is one "best" way, Ive seen people feed the pretty names from an xml file, others rely on IIS7.0 rewrite feature

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