【发布时间】:2016-09-06 18:00:27
【问题描述】:
我在通过 IIS Express 运行 Web API 项目时遇到了 VS 2015 Update 3 这个奇怪的问题。这是我遵循的步骤
1> 启动 Visual Studio 2015(带有更新 3)
2> 选择新的 Asp.NET 4.6.2 web 项目
3> 选择 Empty Project -> 并选中 Web.API 复选框
4> 解决方案准备就绪后,使用 Web API2 Controller with read/write actions 创建新控制器并将控制器命名为 DocumentController
5>项目启动时routeTemplate设置为routeTemplate: "api/{controller}/{id}"。
6> 按 F5 运行应用程序
7> Visual Studio 在 IIS 中将 API 托管为 http://localhost:53394,因此我输入 http://localhost:53394/api/document,我在浏览器中看到了一些 json 结果,如预期的那样。
8> 现在我将 API 项目的项目 URL 从 http://localhost:53394 更改为 http://localhost:53394/api/document 希望我不必每次都输入整个 url。当我更改 URL 时,我得到提示
我选择是。然而,这是行不通的。事实上,现在我的网址变成了http://localhost:53394/api/document/api/document
9> 所以我将项目 URL 改回原来的 http://localhost:53394。这次没有提示我。
10>现在当我尝试使用http://localhost:53394/api/document 访问 api 时出现错误
HTTP 错误 403.14 - 禁止
Web 服务器配置为不列出此内容 目录
但如果我使用 URL http://localhost:53394/api/document/api/document 访问 api,那么我会返回结果。
我尝试重新启动 Visual Studio,但没有成功清除浏览器历史记录 不确定 VS 缓存 URL 的原因和位置。
【问题讨论】:
标签: visual-studio-2015 iis-express