我正在尝试将Swagger与Web API结合使用。我只是使用Visual Studio随附的ASP.NET 4.6模板中的“ Azure API App”模板,其中包括Swashbuckle.Core和SwaggerConfig.cs。该API可以正常工作(我能够成功调用它),但是如果我尝试转到“ http:// mybaseurl / swagger / ”,则会收到此错误:
HTTP错误403.14-禁止Web服务器配置为不列出此目录的内容。
看来Swagger尚未加载。还有其他人知道吗?我似乎无法解决这个问题。谢谢,如果可以提供更多详细信息,请告诉我。
这是我的SwaggerConfig.cs的样子:
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace With.Api
{
public class SwaggerConfig
{
public static void Register(HttpConfiguration config)
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
config.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "With.Api");
})
.EnableSwaggerUi();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用一个非常简单的Angular 2应用程序,我没有使用Angular CLI(为了这个特定的问题,请不要建议我使用CLI).使用JIT编译器时,站点运行时没有任何问题.急切加载的模块以及延迟加载的模块都完全没问题.
我可以成功运行AOT编译器,然后使用Rollup执行树抖动,如Angular 2文档中所述.执行此操作时,站点运行时没有任何问题,因为急切加载的模块,但在尝试转到急切加载的模块时出现错误.这是错误消息:( GET http://atticus.local/app/contacts/contacts.module.ngfactory 404 (Not Found)这是我试图延迟加载的模块)
一个非常基本的问题:
假设上面问题的答案是肯定的,我想知道如何能够将AOT编译和延迟加载一起工作?我已经看到Angular CLI的GitHub问题已经提出了这个问题,看起来已经有了一些解决方案.这假设您使用的是CLI,我不是.我在输出AOT时注意到我的延迟加载模块没有*.ngfactory.ts也没有*.ngsummary.json创建,但仅适用于我急需加载的模块.这可能有意义吗?
作为参考,我为AOT运行的命令ngc -p tsconfig-aot.json具有以下内容tsconfig-aot.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types/"
]
},
"files": [
"app/app.module.ts",
"app/main-aot.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit": true
}
}
Run Code Online (Sandbox Code Playgroud)
然后我跑去rollup -c rollup-config.js累积以执行树摇动.这是 …
angular ×1
angular2-aot ×1
asp.net ×1
c# ×1
lazy-loading ×1
swagger-2.0 ×1
swagger-ui ×1
swashbuckle ×1