6

I am trying to host a new ASP.NET 5 WebAPI project in IIS, and I am using the ASP.NET 5 RC 1 runtime. The project that I am using is the standard generated template for a new ASP.NET 5 WebAPI project. (No code changes.)

I have successfully published the project using the command line, and I can get the application to work in a new web site using a specific port, such as localhost:12345. For example, accessing localhost:12345/api/values returns the values.json data from the project template.

However, when I try to use an IIS Application folder for the project, I am getting a 404 error. In other words, localhost:12345/WebApi1/api/values returns a 404 error. But I can see Kestrel running on a random port in the Event Viewer, and if I access the data on that port, I do get values.json back, so I know Kestrel is running.

Is there something special that needs to be done to get an ASP.NET 5 WebAPI project working in an IIS Application folder under a web site?

Side note: if I use --server.urls to set a port for Kestrel, it's running both on the requested port and the random port logged in the Event Viewer. (So it's actually available from Kestrel from 2 URLs, not the single one configured by --server.urls.)

2
  • 2
    Check this: stackoverflow.com/a/33900458/1184056 Commented Nov 24, 2015 at 23:57
  • Thank you. That did indeed fix the IIS application problem, and it's now working. Commented Nov 25, 2015 at 0:21

1 Answer 1

4

Kiran Challa's link above indeed does fix the problem. Put this in your Configure method in Startup.cs

app.Map("/IISApplicationFolderName", (myAppPath) => this.ConfigureApp(myAppPath, env, loggerFactory));

where IISApplicationFolderName is the name of the IIS application folder that you want to host under. The rest of the configuration code moves to the new method ConfigureApp, since you're delegating your configuration to that method.

This also looks to be a temporary patch until ASP.NET 5 RC2 is released.

Sign up to request clarification or add additional context in comments.

Comments

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.