代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using WebApp.Controllers;
namespace testweb
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//services.AddControllersWithViews();
services.AddControllers();
services.AddSwaggerGen((opt) =>
{
opt.SwaggerDoc("swaggerName", new OpenApiInfo()
{
Title = "swaggerInitialTest",//(必填)申请的标题。
Version = "5.3.1",//(必填)版本号(这里直接写的是Swashbuckle.AspNetCore包的版本号,(有写 v1 的))
Description = "Description",//对应用程序的简短描述。
Contact = new OpenApiContact()//公开API的联系信息
{
Email = "123456789@qq.com",
Name = "DC",
Extensions = null,
Url = null
},
License = new OpenApiLicense()//公开API的许可信息
{
Name = "ZhangSan",
Extensions = null,
Url = null
}
});
//添加中文注释
//拼接生成的XML文件路径
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
//HomeController为当前程序集下的一个类(可自定义一个当前应用程序集下的一个类)[用于获取程序集名称]
var commentsFileName = typeof(TestController).Assembly.GetName().Name + ".xml";
var xmlPath = Path.Combine(basePath, commentsFileName);
opt.IncludeXmlComments(xmlPath);
opt.DocInclusionPredicate((docName, description) => true);
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(opt =>
{
opt.SwaggerEndpoint("/swagger/swaggerName/swagger.json", "ProjectName");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
//endpoints.MapControllerRoute(
// name: "default",
// pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。