StudentManageSystem/Startup.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StudentManageSystem.Code;
using WebApiClient;
namespace StudentManageSystem
{
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)
{
//RazorRuntimeCompilation 运行时编译
services.AddControllersWithViews().AddRazorRuntimeCompilation();
//使用Session
services.AddSession();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<ILoginInfo, LoginInfo>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.LoginPath = new PathString("/Login/Index");
options.LogoutPath = new PathString("/Login/Logout");
options.AccessDeniedPath = new PathString("/Home/Error");
options.Cookie.Name = "_AdminTicketCookie";
//options.Cookie.SameSite = SameSiteMode.None;
//当Cookie 过期时间已达一半时,是否重置为ExpireTimeSpan
options.SlidingExpiration = true;
options.Cookie.HttpOnly = true;
});
//添加HttpClient相关
var types = typeof(Startup).Assembly.GetTypes()
.Where(type => type.IsInterface
&& ((System.Reflection.TypeInfo)type).ImplementedInterfaces != null
&& type.GetInterfaces().Any(a => a.FullName == typeof(IHttpApi).FullName));
foreach (var type in types)
{
services.AddHttpApi(type);
services.ConfigureHttpApi(type, o => {
后面还有 33 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。