4

I'm in the process of migrating some applications from ASP.NET 5 beta7 to RC1. Using HTTPPlatformHandler I am able to run any of these ASP.NET 5 RC1 applications as the root of an IIS site. But they will not run as a subdir (right-click 'add application') of the site. The full response shows:

HTTP/1.1 404 Not Found
Content-Length: 0
Server: Kestrel
X-Powered-By: ASP.NET
Date: Tue, 24 Nov 2015 14:59:04 GMT

It isn't a permissions issue, as the route is served successfully when the app is the root of the site and using the same app pool.

The app pool is configured for 'no managed code' and integrated pipeline.

The web.config for the root application looks like this:

<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
  </system.webServer>
</configuration>

For the sub application I've had to remove the httpplatformhandler handler to avoid the error "Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'httpplatformhandler'".

Now that we have to use kestrel/httpplatformhandler, is it possible to run as an application under a site?

1 Answer 1

10

This problem started with beta8 and is still an open issue in RC1. See ASP.NET IIS Integration issue #14. "That fix is coming." says @davidfowl. "This is a workaround until the fix is available. We're working with the httpPlatformHandler team to fix bugs found in beta8 and rc1."

The workaround is to map the IIS app path in Startup.Configure like this:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.Map("/MyAppPath", (myAppPath) => this.ConfigureMyAppPath(myAppPath, env));
}

public void ConfigureMyAppPath(IApplicationBuilder app, IHostingEnvironment env)
{
    // the actual Configure code
}
Sign up to request clarification or add additional context in comments.

3 Comments

I was pulling my hair out because of this issue, if I could up vote you more than once I would have.
// the actual Configure code Could you expand on this? I'm trying to run my Asp.Net 5 app under IIS (not express) in a virtual directory on port 80 along side other apps in virtual directories. Is this even possible?
@Elton yes, it is possible -- that is the problem this answer solves. What I intended 'the actual Configure code' to mean is just the normal configuration: app.useCors, app.UseMvc(), etc... whatever middleware you are using. The key to getting it working is to use the app.Map("/MyAppPath" ... in my actual implementation I'm supplying the /MyAppPath value from the config.json file so it is not hardcoded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.