ASP.net URL rewrite to a different domain

1

I am trying to rewrite to a url in a blob in azure to return a static html but it always states the following 404.4 error:

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

  • Module: IIS Web Core
  • Notification: MapRequestHandler
  • Handler:StaticFile
  • Error Code: 0x8007007b

Here is my web.config file:

  <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> 

I have added an httphandler and mimemaps and still displays the same error. Also if I change Rewrite to Redirect it works but this changes the url which I don't want.

Thanks in advance.

asp.net
azure
url-rewriting
asked on Stack Overflow Jun 16, 2015 by Estarossa

1 Answer

3

I just faced the same issue today and it turns out it's because URL rewrite only works if you redirect within the same site / web app apparently. See http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx for a solution. hint: you need ARR installed and the "Enable Proxy" box checked under ARR -> Server Proxy Settings

Hopefully it will help you. And if it's too late, well judging by the number of people with that issue on the internet, I'm sure it will help others

answered on Stack Overflow Oct 28, 2015 by tonyM

User contributions licensed under CC BY-SA 3.0