ASP.net URL 重写到不同的域

标签 asp.net azure url-rewriting

我试图重写 azure 中 blob 中的 url 以返回静态 html,但它总是显示以下 404.4 错误:

The file extension for the requested URL does not have a handler configured to process the request on the Web server.

  • 模块:IIS Web 核心
  • 通知:MapRequestHandler
  • 处理程序:静态文件
  • 错误代码:0x8007007b

这是我的 web.config 文件:

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add path="*.html" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />

    <staticContent>
      <remove fileExtension=".css" />
      <mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" />
      <remove fileExtension=".js" />
      <mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
      <remove fileExtension=".json" />
      <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
      <remove fileExtension=".rss" />
      <mimeMap fileExtension=".rss" mimeType="application/rss+xml; charset=UTF-8" />
      <remove fileExtension=".html" />
      <mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
      <remove fileExtension=".xml" />
      <mimeMap fileExtension=".xml" mimeType="application/xml; charset=UTF-8" />
    </staticContent>

    <rewrite>
      <rules>
        <rule name="static" stopProcessing="true">
          <match url="static/(.*)" />
          <action type="Rewrite" url="https://www.blobtest.blob.core.windows.net/static/{R:1}" />
        </rule>
      </rules>
    </rewrite>

  </system.webServer> 

我添加了 httphandler 和 mimemaps,但仍然显示相同的错误。另外,如果我将重写更改为重定向,它会起作用,但这会更改我不想要的网址。

提前致谢。

最佳答案

我今天刚刚遇到了同样的问题,事实证明,这是因为 URL 重写仅在您显然在同一网站/网络应用程序内重定向时才有效。请参阅http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx寻求解决方案。提示:您需要安装 ARR 并在 ARR -> 服务器代理设置下选中“启用代理”框

希望对您有帮助。如果为时已晚,从互联网上遇到该问题的人数来看,我相信这会对其他人有所帮助

关于ASP.net URL 重写到不同的域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30865164/

相关文章:

asp.net-mvc - 重写规则 https ://www to https://IIS7

c# - ASP.NET 基于 ViewState 动态加载控件

c# - Azure Functions 的 HostingEnviornment.QueueBackgroundWorkItem 等效项

azure - 我们可以从管道 azure synapse 在无服务器池中执行 sql 查询吗?

azure - 新的 Azure 门户中的 "Disks"在哪里?

apache - mod_rewrite正在重定向浏览器而不是重写

jquery - 使用 F5 刷新页面时页面布局中断

*.browsers 文件中的 ASP.NET 通配符

c# - 如何使用 DropDownList 的 SelectedIndexChanged 事件

iis-7 - IIS7 URL 重写 : How not to drop HTTPS protocol from rewritten URL?