【问题标题】:ASP.NET | How can I change .aspx extension to .html?ASP.NET |如何将 .aspx 扩展名更改为 .html?
【发布时间】:2017-12-24 22:00:37
【问题描述】:

我尝试过使用 Global.asax 文件的 URL-Routing 方法。但是像图片中那样发生错误。请帮帮我!!

Global Asax File

Error Page

【问题讨论】:

  • 请不要发布代码图片,它不可搜索,我们无法将其复制到答案中。

标签: asp.net url-rewriting url-routing


【解决方案1】:

转到 IIS 管理器 > 单击处理程序映射 > 添加 aspx 用于 html 的相同托管处理程序。

这是我最好的猜测。如果 SimpleHandleFactory 是与扩展无关的,它将起作用。如果不是,它将失败。我自己从未尝试过。

【讨论】:

    【解决方案2】:

    听起来您想将/index.html 重写为index.aspx。您只需将此重写规则添加到您的 web.config:

    <rule name="Rewrite index.html" stopProcessing="true">
        <match url="^index.html" />
        <action type="Rewrite" url="/index.aspx"/>
    </rule>
    

    那么如果你访问http://yourwebserver/index.html,web服务器就会执行/index.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 2014-03-22
      • 2015-05-18
      • 2017-09-23
      • 2010-12-04
      • 2021-12-20
      相关资源
      最近更新 更多