asp.net-core – 虚拟目录中的IIS站点Swagger UI端点
发布时间:2020-12-15 23:55:56 所属栏目:asp.Net 来源:网络整理
导读:Swagger UI端点与登台时的dev不同(不包括域名) IIS配置 public void Configure(IApplicationBuilder app,IHostingEnvironment env,ILoggerFactory loggerFactory) app.UseSwagger(c= { //Change the path of the end point,should also update UI middle war
Swagger UI端点与登台时的dev不同(不包括域名)
IIS配置 public void Configure(IApplicationBuilder app,IHostingEnvironment env,ILoggerFactory loggerFactory) app.UseSwagger(c=> { //Change the path of the end point,should also update UI middle ware for this change c.RouteTemplate = "api-docs/{documentName}/swagger.json"; }); app.UseSwaggerUI(c => { //Include virtual directory if site is configured so c.SwaggerEndpoint(Configuration["Appsettings:VirtualDirectory"]+"api-docs/v1/swagger.json","Api v1"); }); services.AddSwaggerGen(c => { var xmlDocPath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath,"Api.xml"); c.IncludeXmlComments(xmlDocPath); c.DescribeAllEnumsAsStrings(); 具有上述配置 发展 "AppSettings": { "VirtualDirectory": "/" } 分期 "AppSettings": { "VirtualDirectory": "/Api/" } 启动计算机上UI的终点,暂存时间为ON http://localhost:5001/api-docs/v1/swagger.json 但是在登台服务器上也是一样的 http://xxxx:5002/swagger/Api/api-docs/v1/swagger.json 而不是(应该是什么) http://xxxx:5002/Api/api-docs/v1/swagger.json 解决方法
这个问题与环境变量更相关. Swagger支持虚拟目录,然后配置应如下所示.请注意,虚拟目录不会影响UI端点.
app.UseSwagger(c => { //Change the path of the end point,should also update UI middle ware for this change c.RouteTemplate = "api-docs/{documentName}/swagger.json"; }); app.UseSwaggerUI(c => { //Include virtual directory if site is configured so c.RoutePrefix = "api-docs"; c.SwaggerEndpoint("v1/swagger.json","Api v1"); }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 没有App_Data,Asp.net mvc无法运行
- asp.net – 如何让gridview中的一列成为图像?
- asp.net-mvc – UserManager VerifyUserTokenAsync始终为Fa
- asp.net – 验证失败后如何防止页面跳转到顶部位置?
- asp.net-mvc – 在MVC中使用ViewModels进行POST操作
- asp.net – 无法将许可证文件转换为二进制资源
- asp.net – 如何将服务器时间转换为本地时间
- 在ASP.NET中的单个页面上添加SSL
- asp.net-mvc – ASP.NET MVC和Strings不给我编译时错误
- entity-framework – 有没有办法让ASP.NET 5依赖注入解析没
推荐文章
站长推荐
- 实体框架 – EF Codefirst和RDLC Reports
- asp.net-mvc-3 – AZURE ACS – Windows Live ID
- asp.net-mvc – mvc视图中的模型空引用异常
- asp.net-mvc – NUnit中的MbUnit的行属性?
- asp.net-mvc – MVC框架是否配备了丰富的页面设计
- asp.net-mvc – 如何在剃刀代码块中插入空格?
- asp.net – 在jQuery对话框中的窗体中,MVC中通常
- asp.net-mvc – 使用Session进行Asp.net MVC3长轮
- asp.net-mvc – 使用Facebook和Twitter登录ASP.N
- asp.net – WCF – 找到了该合同的多个端点配置
热点阅读