5

Let me preface by saying that I have a Linux background and developing on Windows is fairly new to me.

I am working on a ASP.NET project that I have opened in Visual Studio. The project was originally set up to run via IIS. VS helpfully asked me if I would like to try IIS Express and I said yes. The app had a few hiccoughs initally, but that's because the code is old and huge. After resolving those issues, the app loads fine, except for any static files. I get a 404 Not Found for resources that actually exist on the filesystem.

That physical path you see in the photo exists in a folder right next to the Web.config file. I can load aspx files from an exec directory that is a sibling of the graphics directory. The graphics directory is where the favicon.ico file I'm trying to load in this picture is.

I've read a lot of documentation today for IIS and IIS express and none of them have mentioned having to do anything special for static files. Maybe I'm just thick. If my Web.config is needed let me know and I can attach it here.

IIS Express Error page

Edits:

1) Some progress on this. I am getting the exact same error under full-blown IIS as well. My static content does not show up.

2) Here's web.config as requested

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <loggingConfiguration name="loggingConfiguration" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Enterprise Library Logging" formatter="Text Formatter" log="" machineName="." traceOutputOptions="DateTime, Timestamp, ProcessId" />
      <add name="W3C Rolling Flat File Trace Listener" type="App.W3CLogTraceListener, App, Version=1.0.0.0, Culture=neutral" listenerDataType="App.W3CLogTraceListenerData, App, Version=0.0.0.0, Culture=neutral" fileName="appA65.log" fileHeader="date time session-id client-ip page url form-data cookie" footer="" formatter="Text Formatter" header="" rollInterval="Midnight" timeStampPattern="yyyy-MM-dd" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{message}" name="Text Formatter" />
    </formatters>
    <logFilters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" enabled="false" name="Logging Enabled Filter" />
    </logFilters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="W3C Rolling Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Event Log Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <appSettings>
    <!-- To enable or disable IETP user session management, true to enable, false to disable -->
    <add key="IetpSessionEnabled" value="false" />
    <!-- To specifies where the folder for session files -->
    <add key="IetpUserSessionServerPath" value="d:\apps\ietpusersessions" />
    <!-- To determines the duration of s user session in terms of minutes -->
    <add key="IetpUserSessionLengthInMinutes" value="600" />
    <!-- to enable/disable sending out email on exceptions, true to enable, false to disable -->
    <add key="EmailAlertEnabled" value="true" />
    <!-- the exception email alert list, seperated by comma -->
    <add key="EmailAlertToAddress" value="alice@example.com" />
    <!-- email sender address -->
    <add key="EmailAlertFromAddress" value="bob@example.com" />
    <!-- to enable or disable Pdf print, wehn set "true", all user local print requests will be -->
    <!-- processed on the server and the final PDF will be rended in browser -->
    <add key="PdfPrintEnabled" value="true" />
    <add key="PdfPrintServiceUrl" value="https://example.com/PdfPrintService/PdfPrintService/PDFPrint.aspx" />
    <add key="FooterDisclaimer" value="Footer here" />
  </appSettings>
  <system.web>
    <httpRuntime targetFramework="4.0" requestValidationMode="2.0" />
    <!-- <httpRuntime executionTimeout="300" /> -->
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.5.1" />
    <customErrors defaultRedirect="~/exec/generalError.aspx" mode="Off" />
    <sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" cookieless="false" stateNetworkTimeout="11" timeout="600" />
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="URLWriteHttpModule" />
      <add name="URLWriteHttpModule" type="App.URLWriteHttpModule" />
    </modules>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.aspx" />
        <add value="Default.asp" />
        <add value="Default.htm" />
        <add value="index.htm" />
        <add value="index.html" />
      </files>
    </defaultDocument>
    <tracing>
      <traceFailedRequests>
        <add path="*">
          <traceAreas>
            <add provider="ASP" verbosity="Verbose" />
            <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
            <add provider="ISAPI Extension" verbosity="Verbose" />
            <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI" verbosity="Verbose" />
          </traceAreas>
          <failureDefinitions timeTaken="00:00:00" statusCodes="500-599" verbosity="Error" />
        </add>
      </traceFailedRequests>
    </tracing>
        <handlers accessPolicy="Read, Execute, Script" />
  </system.webServer>
</configuration>

Final Edit- I was never really able to figure out what went wrong. A re-install of the OS fixed this issue and I was never able to duplicate it again.

Ananth
  • 848
  • 11
  • 26
  • Have you tried to add a MIME type for .ico files, just like in this answer (for .json files): https://stackoverflow.com/questions/8158193/how-to-allow-download-of-json-file-with-asp-net – Simon Mourier Dec 01 '18 at 01:29
  • The site itself is pretty old, but I'm running it on IIS express 10. it's configuration file already has an entry for ico files under staticFiles. – Ananth Dec 01 '18 at 04:51
  • @Ananth Can you add ` ` in web.config and see if that solves your issue? – Dipen Shah Dec 01 '18 at 14:22
  • @DipenShah nope, I'm still getting a 404 not found. – Ananth Dec 05 '18 at 06:41
  • are the static files included in your project or are they just on disk? – Mike Dec 05 '18 at 19:06
  • How would they be included? They are in a directory that's adjacent to my global.aspx file. – Ananth Dec 05 '18 at 19:12
  • If I right click the directory in Solution Explorer, I see an option to exclude it from the project. So it must be included, right? – Ananth Dec 07 '18 at 05:42
  • As @SimonMourier says I think this could be a mime type issue, you said you have something for `.ico` in config but I'd expect to see it as a `mimeType` in the `web.config` which it's not. Can you try a more standard static resource (.html / .png ) and see if you get the same problem? – dougajmcdonald Dec 07 '18 at 12:24
  • I tried it first on a png. To give you some more insight, the only thing that dont give 404s are aspx files. – Ananth Dec 07 '18 at 13:11
  • @Ananth can you post your .csproj file? – Pavel Levchuk Dec 07 '18 at 13:34
  • I'm having the same issue; for me, it's a case sensitivity thing. I'm supporting a website that is case sensitive. I converted the file system folder the site is in to case sensitivity; I get 404's on index.html (and I even created an INDEX.HTML). Static content is enabled. – J. Gwinner Jun 07 '23 at 15:52
  • I'm not working on that project anymore so I'm unable to verify, but this is the closes this question has come to being answered. You should post this as an answer. – Ananth Jun 10 '23 at 19:59

3 Answers3

2

Can you try adding this?

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

IIS Pre conditions

Did you enable static content in IIS?

enter image description here

  1. Check your gloabl.asax this kind of line exists

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); or routes.IgnoreRoute("{favicon}", new {favicon=@"(./)?favicon.ico(/.*)?"});

or something similar

  1. Comment url rewrite part and check its working?

And I believe you double check that file exists or not in correct path :)

cdev
  • 5,043
  • 2
  • 33
  • 32
0

Ananth,

Have you enabled static content? Have a look at https://forums.iis.net/t/1233905.aspx?how+to+enable+static+content+in+IIS+7+5+within+windows+server+2008+R2

oakman
  • 297
  • 1
  • 8
0

Check if your static content is published via MSBuild. If not, add these lines to your .csproj file:

<ItemGroup>
    <Content Include="graphics\**\*.*" />
</ItemGroup>
Pavel Levchuk
  • 757
  • 8
  • 11