简体   繁体   中英

MVC 6 - Getting 404 error on IIS

This is all I get

Status Code: 404; Not Found

Here is the environment.

  • IIS 7.5
  • Windows 2008 R2
  • ASP.NET 5 RC and HttpPlatformHandler are installed.

...and what I've done.

1) Checked the log directory that stdoutLogFile in the web.config points to. Don't see any errors. Just a lot of these:

info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET <websiteName>

2) RDP in and can browse to the site after running web.cmd in the approot directory. Site runs fine that way. Can not access it with IIS.

3) Startup.cs/configure contains

app.UseStatusCodePages();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();

4) Local publish. Copy to server. Website points to wwwroot directory. Approot sits next to it.

5) processPath points to "..\\approot\\web.cmd".

6) Published with DNX version dnx-clr-win-x86.1.0.0-rc1-update1. Also tried the same 64 bit version.

7) HttpPlatformHandler is installed.

8) Checked the IIS error logs and didn't see anything interesting.

What should I try next?

Update

I have these environment variables mapped.

DNX_HOME - C:\Users\<user>\.dnx
DNX_PACKAGES - C:\Users\<user>\.dnx\packages
DNX_PATH - C:\Users\<user>\.dnx\bin\dnvm.cmd

Visual C++ Redistributable for Visual Studio 2012 Update 4 is installed.

1) Recycle the application pool each time you do a troubleshooting step.

2) Try a vastly simplified application. If you still receive a 404, then we know something is up with the hosting not with the application.

The following super-simple application is working for us in IIS.

C:/App00/Startup.cs

using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;

namespace App00
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(async context =>
            {
                await context.Response.WriteAsync("Hello from RC1!");
            });
        }
    }
}

C:/App00/project.json

{
    "dependencies": {
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-*"
    },
    "frameworks": {
        "dnx451": {}
    },
    "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel"
    }
}

C:/App00/wwwroot/web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" 
           modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" 
         stdoutLogEnabled="false" startupTimeLimit="3600"/>
  </system.webServer>
</configuration>

Restore and Publish

dnvm use 1.0.0-rc1-update1 -runtime clr
dnu restore
dnu publish --runtime active

IIS Configuration

Physical Path     C:\App00\bin\output\wwwroot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM