taylonr
taylonr

Reputation: 10790

What causes a 404.4 on IIS 7.5 for delivering a static file?

I'm trying to set my default page to Index.html on an ASP.NET site running on IIS7.5. I keep getting a 404.4 which tells me that a handler is not set up. However, I have a <handler> and an <httpHandlers> value set up for my html pages. I've also specified the default document. Yet I keep getting a 404.4.

I CAN browse to myuri/index.html but I can't get it to load as the default.

Any suggestions?

Here's my web.config

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
  <appSettings />
  <connectionStrings />
  <system.web>
    <authentication mode="Windows" />
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.0" />
    <httpHandlers>
      <add path="*.html" verb="*" type="System.Web.StaticFileHandler" />
      <add path="~/assets/*" verb="*" type="System.Web.StaticFileHandler"/>
      <add verb="*" path="*.rastahook" validate="false" type="OpenRasta.Hosting.AspNet.OpenRastaRewriterHandler, OpenRasta.Hosting.AspNet" />
    </httpHandlers>
    <httpModules>
      <add name="OpenRasta" type="OpenRasta.Hosting.AspNet.OpenRastaModule, OpenRasta.Hosting.AspNet" />
    </httpModules>
    <pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID" />
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true" />
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="/index.html" />
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
        <rule name="Remove WWW" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
          </conditions>
          <action type="Redirect" url="threetasks.apphb.net{PATH_INFO}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>

    <httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>
    <urlCompression doStaticCompression="true" />
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=Edge,chrome=1" />
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <add name="OpenRasta" type="OpenRasta.Hosting.AspNet.OpenRastaModule, OpenRasta.Hosting.AspNet" />
    </modules>
    <handlers accessPolicy="Script,Read">
      <clear />
      <add name="StaticFile" path="index.html" verb="*"
           modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
      <add name="StaticFiles" path="~/assets/*" verb="*"
           modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
      <add name="OpenRasta" verb="*" path="*.rastahook"
           type="OpenRasta.Hosting.AspNet.OpenRastaRewriterHandler, OpenRasta.Hosting.AspNet" />
    </handlers>
    <staticContent>
      <!-- Set expire headers to 30 days for static content-->
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />

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

      <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
      <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
      <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
      <mimeMap fileExtension=".webm" mimeType="video/webm" />

      <!--<mimeMap fileExtension=".svg" mimeType="images/svg+xml" />-->
      <!--<mimeMap fileExtension=".svgz" mimeType="images/svg+xml" />-->

      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".otf" mimeType="font/otf" />
      <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
    </staticContent>
  </system.webServer>
</configuration>

Upvotes: 2

Views: 4338

Answers (3)

taylonr
taylonr

Reputation: 10790

What we ended up doing was splitting the project. Our goal was to have a service backend with a think JavaScript front end. Some of this is to try out different patterns and ideas we have. I'm writing the service and my friend is writing the front end. After talking about it, they don't need to be in the same project.

That is, I'll create an API and he'll create a client that can be hosted anywhere. With that in mind, my site will now just do API work, and will not need to deliver any html as a default page.

Upvotes: 0

EdSF
EdSF

Reputation: 12351

Taking a step back....where are you setting the default document?

If you set it in web.config, then you are saying that the ASP.Net runtime will/should handle .html extension. In other words, web.config pertains to ASP.Net.

Have you set the default document in IIS? If its just a static file, there is no need for ASP.Net to even be involved - IIS should handle htm/html files out of the box.

Upvotes: 0

irfanmcsd
irfanmcsd

Reputation: 6561

For handling static content in iis 7.5, you need to register mime type via the following element in web.config file within element. I am mostly used for mp4 videos withot it 404.4 error arises.

<staticContent> 
 <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> 
 <!-- for html may be -->
 <mimeMap fileExtension=".html" mimeType="text/html" /> 

</staticContent>

Upvotes: 2

Related Questions