car*_*son 5 .net c# asp.net asp.net-mvc asp.net-web-api
我有一个完全在本地运行的ASP.NET MVC项目.它有一些继承自Controller的控制器和一些继承自ApiController的控制器.我的路线在下面.当我在本地通过Visual Studio运行项目时,它完美地运行.我可以点击所有端点并获得预期的响应.当我将其部署到云服务器(Windows Server 2008 r2)时,只有:Controller端点可以工作(那些在/ p/{controller}/{action}).没有任何端点:ApiController工作.我得到以下所有错误:
{"$id":"1","Message":"No HTTP resource was found that matches the request URI 'http://DOMAIN/CONTROLLER'.","MessageDetail":"No type was found that matches the controller named 'CONTROLLER'."}
Run Code Online (Sandbox Code Playgroud)
我的路线:
在RouteConfig.cs中:
routes.MapRoute(
name: "Default",
url: "p/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Redirect", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
在WebApiConfig.cs中:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}",
defaults: new { }
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1786 次 |
| 最近记录: |