WebAPI学习笔记(12)HTTPS发布时出现Swagger页面无法显示问题的解决方案
1、打开SwaggerConfig.cs文件,找到c.RootUrl注释部分,并取消注释。
//c.RootUrl(req => GetRootUrlFromAppConfig(req));
2、生成GetRootUrlFromAppConfig方法即可:
private static string GetRootUrlFromAppConfig(HttpRequestMessage message) { var virtualPathRoot = message.GetRequestContext().VirtualPathRoot; var schemeAndHost = "https://" + message.RequestUri.Host; return new Uri(new Uri(schemeAndHost, UriKind.Absolute), virtualPathRoot).AbsoluteUri; }