Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API on IIS7 - Not Found 404

Tags:

asp.net

iis

I have a simple web api project. When I deploy it on IIS 7.5 on Win 7 using Publish feature under VS2010, it works fine. But when I deploy it to IIS 7 on Windows server 2008 (msinfo32 shows version is 6.0.6002 service pack 2), it returns 404.0 Not Found for the same GET request that worked on IIS 7.5

Module IIS Web Core 
Notification MapRequestHandler 
Handler StaticFile 
Error Code 0x80070002 

I have googled and done all suggestions that I can but none of them worked form me.

Any idea how to fix it?

Thanks

like image 246
HNGO Avatar asked Nov 04 '22 09:11

HNGO


2 Answers

I would make sure you are using the correct url/location when making the GET request, if your making the GET request off of your own project then it could change if you deploy to another location.

If you need a more specific answer please give some more details and code.

like image 129
Pseudonym Avatar answered Nov 11 '22 16:11

Pseudonym


I was missing .NET Framework 4.5 on the Web Server running the IIS 7.5 Microsoft .NET Framework 4.5

These two answers helped me, but in my case I had to change some publishing settings too

MVC 4 Web Api IIS7.5 HTTP 404 Page Not Found

ASP.NET Web API returns 404 for PUT only on some servers

I was using File System publishing method and I had to check the file delete option. There were files on the web server from previous build/publish that caused the problem in my case.

enter image description here

Lastly, I was publishing the app on a website sub folder. The url was something like www.myApp.com/spa/ so I had to change the path to the WebAPI in the js configuration to be

www.myApp.com/spa/api/webApiController instead of

www.myApp.com/api/webApiController

like image 22
mitaka Avatar answered Nov 11 '22 16:11

mitaka