.NET的Web API - 404 - 文件或目录未找到 [英] .NET Web Api - 404 - File or directory not found
问题描述
在短的话,一切都运行在本地机器上,但不会在部署到服务器的A。
In short words, everything works on local machine but doesn't when deployed to server "A".
我敢肯定,成才在服务器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.
所以我在这里AKS帮助和什么样的问题可能是,这样我可以负责服务器的A的人建议的想法,或任何修改,使我的项目,使其在那里工作
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...
我使用的Web API和一个路由在Global.asax这样定义的:
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 });
我打电话使用Jquery Ajax和剑道UI控制器,因为这样的:
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";
}
}
再次一切本地服务器上的伟大工程,但是当我部署它,我得到的每一个Web API调用:
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.
没有别的。
需要考虑的事项:
- 我编译该项目使用.NET 4.0框架。
- 在服务器A被设置为使用.NET 4.0的经典网站(这可能是一个问题?)
- 我不认为MVC 4安装在服务器的A。难道网络API需要MVC?
- 服务器A运行IIS 7
我添加了下面到web.config文件中,但仍获得了404错误:
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.
感谢您的帮助!
推荐答案
下载MVC4使用ASP.NET的WebAPI。 http://www.microsoft.com/en-us/download /details.aspx?id=30683
Download MVC4 to use ASP.NET WebAPI. http://www.microsoft.com/en-us/download/details.aspx?id=30683
这篇关于.NET的Web API - 404 - 文件或目录未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!