1
我正在開發使用Microsoft Web API 2和SwaggerUi的RESTful Web服務。爲什麼在owin實施之後,招搖即止?
我已經刪除了默認的Global.asax,並使用OWIN配置了我的Web API。這是我的Startup.cs代碼:
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
config.MessageHandlers.Add(new JWTAuthenticationHandler() { StopPipelineHandling = true });
config.Filters.Add(new MyActionFilter());
SwaggerConfig.Register();
app.UseWebApi(config);
}
這是我的SwaggerConfig.cs代碼:
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyNamespace.WebApi");
})
.EnableSwaggerUi(c =>
{});
此操作之後,我無法查看招搖的操作,如下面的圖片:
請問,你能幫助我嗎?
謝謝很多
我建議您使用瀏覽器開發人員工具(F12)查看從您的Web API返回的內容。很可能你得到了錯誤狀態代碼,然後你必須修復。 –
嗨馬丁,我試過了,我可以正確使用我的API。 – ilMattion
試試這個,而不是使用「GlobalConfiguration.Configuration」將httpConfiguration傳遞給swagger寄存器。 公共靜態無效寄存器(HttpConfiguration配置) { config.EnableSwagger(C => { c.SingleApiVersion( 「V1」, 「MyNamespace.WebApi」);}).EnableSwaggerUi();} – Prashant