IIS 7 fails to serve .aspx pages but works with default files


I have deployed an ASP.NET 4 web site to IIS 7 on Windows Server 2008. When I browse to the root folder, or any other folder in the site, the server responds by delivering the default page Default.aspx as you would expect. However, when I request a specific page with an .aspx extension, I get a 404 error.

For example, when I request:


the server successfully delivers http://localhost/MyWeb/Default.aspx. However, if I explicitly request:


then IIS responds with a 404 error.

The error details are as follows:

Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error code: 0x80070002

The .NET framework is obviously installed and working, since I can get to default pages. By the way, I have observed that when the server fails and shows a 404 error page, the URL that I entered (such as http://localhost/MyWeb/Default.aspx) drops the extension (and reads http://localhost/MyWeb/Default).

I have tried running aspnet_iisreg -i and restarting the server, but things haven't changed.

What am I missing? Thank you.

UPDATE. I am posting here the web.config of my site. There are no other config files that apply to it.

<?xml version="1.0" encoding="utf-8"?>
  For more information on how to configure your ASP.NET application, please visit

    <add key="DatabaseServer" value="CONWAY\SQLEXPRESS"/>
    <add key="DatabaseName" value="KaleidoScape"/>
    <add key="User" value="KaleidoScapeUser"/>
    <add key="Password" value="Scape1!"/>


    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />

        <add namespace="System.Web.Optimization" />
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
        <add tagPrefix="uc" tagName="FileGallery" src="~/Controls/FileGallery/FileGallery.ascx" />

    <authentication mode="Forms">
      <forms defaultUrl="~/App" loginUrl="~/Default.aspx" slidingExpiration="true" timeout="120" name="Incipit.KaleidoScape" />

      <allow users="*" />


  <location path="App">
        <deny users="?" />

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="" newVersion="" />
        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="" newVersion="" />
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />

UPDATE. The IIS log entries for a failed request are as follows:

2016-10-23 21:13:22 GET /MyWeb/MyPage.aspx - 80 - Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.0;+WOW64;+Trident/5.0) 301 0 0 46
2016-10-23 21:13:22 GET /MyWeb/MyPage - 80 - Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.0;+WOW64;+Trident/5.0) 404 0 2 0

Note that there are two entries. The first one corresponds to MyPage.aspx, which is the page I requested by typing on the URL field. This results in a 301 (moved permanently) error. Immediately after, there is an entry for the same page without the .aspx extension, which results in a 404 error with substatus 0. I don't understand why the full URL gets a 301, and why the server then tries to deliver (and fails) a page without the extension.

UPDATE. I've just run an interesting experiment. I created a new web application on my server, having a single Test.aspx file. It worked as expected, i.e. the server delivers the page when you request it explicitly. Then I copied all the contents from the web site that is giving me headaches, and Test.aspx stopped working! Then, I deleted everything from this web except for the Test.aspx file, and it didn't revert back to working, but stayed failing. In conclusion, there's something in the web content that screws things up, and which persists after you delete the content. This is a web site I created with Visual Studio 2015 by using a project template that comes with Bootstrap and a few other things. I am utterly confused.

asked on Super User Oct 20, 2016 by CesarGon • edited Oct 23, 2016 by CesarGon

1 Answer


After much research, I found a solution to this. I should say that I know how to fix the problem, but I am still not sure why the problem occurs.

The issue is related to the "friendly URLs" mechanism that is available in IIS 7. I deactivated them by changing the code in App_Start\RouteConfig.cs from:

var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;


var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Off;

This has fixed the issue. As far as I understand, friendly URLs are about dropping file extensions, and I guess that's why I get the 301 error and a subsequent attempt for an extension-less file every time I request a page. However, I don't know why IIS fails to deliver the file.

Anyway, it's fixed now. Thanks to all who helped diagnose the problem.

answered on Super User Oct 24, 2016 by CesarGon • edited Oct 24, 2016 by CesarGon

User contributions licensed under CC BY-SA 3.0