在 VS2013 WebAPI 项目上运行 swagger 时,出现以下错误
<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 url 中附加 /swagger。
执行第 4 步后,出现上述错误。
请帮忙。