在VS2013 WebAPI项目上运行时,我收到以下错误
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Object reference not set to an instance of an object.
</ExceptionMessage>
<ExceptionType>System.NullReferenceException</ExceptionType>
<StackTrace>
at Swashbuckle.Application.SwaggerDocsConfig.DefaultRootUrlResolver(HttpRequestMessage request) at Swashbuckle.Application.SwaggerDocsConfig.GetRootUrl(HttpRequestMessage swaggerRequest) at Swashbuckle.Application.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.HttpServer.<>n__FabricatedMethod5(HttpRequestMessage , CancellationToken ) at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
</StackTrace>
</Error>
已完成步骤 1.安装SwashBuckle Nuget包 2.修改Swagger.cs文件以包含基本的必需代码。 3.运行WebApi。 4.在API网址中附加/ swagger。
实施第4步后,我得到了上述错误。
请帮忙。
答案 0 :(得分:0)
安装Nuget包Microsoft.AspNet.WebApi.WebHost版本5.2.3