我有一个预先存在的 VB.NET Web 应用程序,它在 Windows Server 2012 R2 的 IIS 8 上运行。应用程序需要处理我使用 APIController 接口实现的新 API 调用(例如 localhost/test/ping)。我能够在本地 Visual Studio 上成功运行 API 调用,但是一旦将其部署到 IIS,该 url 就会返回 404 错误。
经过一些挖掘和研究,我认为部分问题是 Web 应用程序在处理程序映射中没有 ExtensionlessUrlHandler-Integerated-4.0。查看配置,显然部分前提条件是应用程序不能是经典模式下的我,而我的是。我无法切换到会破坏我的应用程序的集成模式。
有没有办法绕过这个限制。
更新:添加 web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="MVC" path="*." verb="*" type="" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="File" requireAccess="None" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="4194304" />
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
更新:添加了源代码
测试控制器.vb
<RoutePrefix("message")>
Public Class PingController
Inherits ApiController
Public Sub New() {
...
}
<Route("")>
<HttpGet>
Public Function GetMessage As String
Return "Hello World"
End Function …Run Code Online (Sandbox Code Playgroud)