我有一个相当简单的 Web API 项目,在 WebApiConfig.cs 的默认路由下有以下路由:
config.Routes.MapHttpRoute(
name: "ChildApi",
routeTemplate: "api/{parentController}/{parentId}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
这可以在 VS2012 开发服务器下正常运行并导航到我的测试 URI ( /api/team/1/entries/2013-04-19
) 返回正确的结果。一旦我发布它并尝试使用 IIS8 访问相同的 URI,我会收到以下 404 错误:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
Create the content on the Web server.
Review the browser URL.
Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
所有非嵌套路由(例如/api/team/1
)工作正常,但似乎这个特定的路由被解释为一个静态文件,而 IIS 正试图这样提供它?以前有没有其他人看到/解决过这个问题?