ASP.NET 5 WebAPI Hosting in IIS Using Virtual Directory / Application

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 I am using is the standard generated template for a new ASP.NET 5 WebAPI project. (No code changes.)

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

However, when I try to use the IIS application folder for the project, I get error 404. In other words, localhost: 12345 / WebApi1 / api / values ​​returns error 404. But I see that Kestrel is working on a random port in the event viewer. and if I access the data on this port, I return .json values, so I know that Kestrel is working.

Is there anything special that needs to be done to get an ASP.NET 5 WebAPI project running in the IIS application folder under the website?

Note: if I use -server.urls to set the port for Kestrel, it works on both the requested port and the random port registered in the event viewer. (Thus, it is actually accessible from Kestrel from 2 URLs, and not from one configured with -server.urls.)

+5
source share
1 answer

Link Kiran Challa really really fixes 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 for which you want to host it. The rest of the configuration code moves to the new ConfigureApp method, as you delegate your configuration to this method.

It also looks like a temporary patch until ASP.NET 5 RC2 is released.

+3
source

Source: https://habr.com/ru/post/1236754/


All Articles