.NET Web Api - 404 - File or directory not found

狂风中的少年 提交于 2020-01-04 10:36:10

问题


In short words, everything works on local machine but doesn't when deployed to server "A".

I'm sure someting is missing in server "A", but I don't know what it is, and I don't have access there to make changes or proper testing.

So I'm here to aks for help and ideas of what the problem may be so that I can advise the person in charge of server "A", or whatever changes I need to make on my project to make it work there.

That being said, lets talk about my project...

I'm using Web Api, and a route is defined in the global.asax as such:

RouteTable.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
           defaults: new { id = System.Web.Http.RouteParameter.Optional });

I'm calling the controllers using Jquery ajax and Kendo UI, as such:

(this is a fake example just to prove the point)

read: {
        url: function () {
               return "../api/Member/123";
        }
}

Again, everything works great on local server, but when I deploy it, I get for every web api call:

404 - File or directory not found.

Nothing else.

Things to consider:

  • I'm compiling the project with .NET 4.0 framework.
  • The website on server "A" is set up to use .NET 4.0 classic (could this be a problem?)
  • I don't think MVC 4 is installed in server "A". Does Web Api requires MVC?
  • Server "A" is running IIS 7

I added the following to the web.config file, but still get the 404 error:

<modules runAllManagedModulesForAllRequests="true"/>

Let me know if you need any other information.

Thanks for your help!!


回答1:


Download MVC4 to use ASP.NET WebAPI. http://www.microsoft.com/en-us/download/details.aspx?id=30683



来源:https://stackoverflow.com/questions/15622720/net-web-api-404-file-or-directory-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!