相关疑难解决方法(0)

在MVC网络核心中找不到Swagger页面404

我有一个全新的.NET-Core Web API项目,我想使用API​​版本控制和调整。

当我尝试查看摇摇欲坠的页面时,我得到404。但是,模板随附的默认ValuesController有效。

这是我的设置:

启动文件

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        // Add API Versioning
        services.AddApiVersioning(
            options =>
            {
                options.DefaultApiVersion = new ApiVersion(1, 0);
                options.AssumeDefaultVersionWhenUnspecified = true;
                options.ReportApiVersions = true;
            });

        // Add Swagger
        string pathToDoc = "RegistriesApi.xml";
        services.AddSwaggerGen(options =>
        {
            options.SwaggerDoc("v1",
                new Info
                {
                    Title = "Registries API",
                    Version = "v1",
                    Description = "A simple api to interact with AMA registries information",
                    TermsOfService = "None"
                });

            string filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, pathToDoc);
            options.IncludeXmlComments(filePath);
            options.DescribeAllEnumsAsStrings();
        });
    }
    ...
    public void …
Run Code Online (Sandbox Code Playgroud)

c# api swagger asp.net-core

2
推荐指数
1
解决办法
2844
查看次数

标签 统计

api ×1

asp.net-core ×1

c# ×1

swagger ×1