Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当我打开新页面时,有时会出现登录页面_C#_Asp.net Mvc 5 - Fatal编程技术网

C# 当我打开新页面时,有时会出现登录页面

C# 当我打开新页面时,有时会出现登录页面,c#,asp.net-mvc-5,C#,Asp.net Mvc 5,我最近发布了我的第一个编程web应用程序,在此之前,我的web应用程序在本地服务器上运行良好,该服务器在本地网络上运行。在应用程序中,用户必须首先登录才能打开和浏览页面。现在,当用户登录时,页面会很好地打开,但当用户打开页面时,登录页面会出现,要求登录。这种行为经常发生 我的登录代码如下: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(Login

我最近发布了我的第一个编程web应用程序,在此之前,我的web应用程序在本地服务器上运行良好,该服务器在本地网络上运行。在应用程序中,用户必须首先登录才能打开和浏览页面。现在,当用户登录时,页面会很好地打开,但当用户打开页面时,登录页面会出现,要求登录。这种行为经常发生

我的登录代码如下:

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (!ModelState.IsValid)
       {
           return View(model);
       }

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, 
shouldLockout: false);
     switch (result)
     {
         case SignInStatus.Success:
              return RedirectToLocal(returnUrl);
         case SignInStatus.LockedOut:                        
              return View("Lockout");
         case SignInStatus.RequiresVerification:
              return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = 
              model.RememberMe });
         case SignInStatus.Failure:
              default:
         ModelState.AddModelError("", "UserName or Password is not correct");
              return View(model);
    }
}
[HttpPost]
[异名]
[ValidateAntiForgeryToken]
公共异步任务登录(LoginView模型,字符串返回URL)
{
如果(!ModelState.IsValid)
{
返回视图(模型);
}
var result=wait SignInManager.PasswordSignInAsync(model.Email、model.Password、model.RememberMe、,
shouldLockout:false);
开关(结果)
{
案例标志状态成功:
返回重定向到本地(returnUrl);
案例标志状态锁定输出:
返回视图(“锁定”);
案例标志状态。要求验证:
return RedirectToAction(“SendCode”,new{ReturnUrl=ReturnUrl,RememberMe=
model.RememberMe});
案例信号状态故障:
违约:
AddModelError(“,”用户名或密码不正确”);
返回视图(模型);
}
}
在web.config文件中,我写道:

<system.web> 
    <authentication mode="None" />
    <sessionState timeout="30" />
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
 </system.web>


。。。请帮我解决这个问题

sessionState timeout=“30”
看起来可能意味着“30秒后自动注销”。不,现在是30分钟。出于兴趣,为什么你创建了一个新项目,但目标是一个非常旧版本的.net?4.8是最新版本,将有大量4.5.2中没有的功能和错误修复(我认为这是几年后的EOL)。我已尝试将时间增加到1200,以确保会话超时是否以秒为单位设置,但问题仍然存在。对于.net版本,我在两年前开发了该应用程序,在本地网络上运行时,我对该版本没有任何问题。