// 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.UseSession(); ComHttpContext.Configure(app.ApplicationServices.GetRequiredService <Microsoft.AspNetCore.Http.IHttpContextAccessor>()); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public IActionResult jiluyemian() { //法一,ViewBag特性是在作用域内才有效,因此不能写在ajax控制器中,且所有页面都要写这一段 ComHttpContext session = new ComHttpContext(); string result = session.Get("logtype"); ViewBag.session = result != null ? result : "0"; return(View()); }
//验证账号状态 public ActionResult VerifyLogin() { ComHttpContext session = new ComHttpContext(); string result = session.Get("logtype"); return(Json(new { result })); }