I'm trying to figure out how to work IIS and how to host my asp.net applications. I ask the question, because it does not work. I am doing the right steps (as I think the right ones), but in the end I get a 404 error, in general, let me describe how I did, maybe I didn’t understand something. Please correct me if I did something wrong.

Installing IIS:

enter image description here

After I ticked the necessary components, and in Visual Studio I created a simple project Asp.Net WebApi. Built api with Post and Get methods, no matter what they do. It turns out if I run through Visual Studio, that is, the project is temporarily hosted on IIS Express, then I can easily see the results of the requests. Now I need to publish.

I chose IIS, then I chose FileSystem and indicated the path to some folder, I published well. Then I go to the IIS Manager. I tried here 2 ways in different ways:

The first is to create a site, specifying the physical path to the folder of the project publication, port 80, the host name localhost. So in the browser I used the following url localhost / api / Word. I get, error 404, error code 0x80070002.

The second way is not to create a separate site, but to add a virtual folder to the Default Web Site, specifying the path to the location of the project itself. Then I converted to an application. I'm trying to access using url: localhost / MyFirstApi / api / Word. Again, I get 404 and error code 0x80070002.

All steps are taken from the guides, no amateur. Can anyone help figure out?

Screen of the most result url:

enter image description here

  • I suspect that this is all connected with port 8080, but I don’t know what to do with it, because it was taken by the PID 4 system. I looked at the laptop, there the system takes up other ports, hmm, strange. - Sergey Ivanyuk
  • Not in the port case. Were busy ports 80 and 8080, 8080 I was able to release, created a site where indicated a different port (the one that freed 8080), in the end the same thing. Hz sales what to do - Sergey Ivanyuk
  • At the moment, 80th and 8080 are occupied by the Web Publishing Service, without which IIS does not work, looking further for what it is - Sergey Ivanyuk

1 answer 1

The problem arose due to 2 reasons:

1) I used the wrong application pool. For ASP.NET and WEBapi, including, you need a pool for .NET 4.0, and the default is .Net 2.0

After installing the necessary pool, the problem is not lost. Since, in addition to the application pool, there must be the necessary ISAPI filters for APS.NET 4.0. I do not quite understand what these filters are, so leave an explanation on those who fumble.

2) In general, as added. through the command line, changed the directory to C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319. After I registered the command to install ASP.NET v4.0:. \ Aspnet_regiis.exe -i

At the end of the installation, everything worked right away and the necessary 4.0 filters appeared. Fixed Guide: https://alexanderzeitler.com/articles/HTTP-Error-4040---Not-Found-(MapRequestHandler--StaticFile)-when-deploying-WCF-Web-API-on-IIS-7x/