嗨,这个错误已经困扰了我好几天了,我不知道为什么它发生了我记得的最后一件事是在我的电脑上安装VS2015,现在我的网络应用程序不再启动了。
BTW此应用程序是在.net framework 3.5中构建的,目前位于该站点的登录页面中。即使我的凭据是正确的,我也无法重定向到主页,并且它总是抛出此错误。请看下面的图片;
重载重定向方法重定向(url,endresponse)无法解决问题,不会抛出异常,但之后不会重定向到我的主页。检查下面的代码。
try
{
lblErrorLogin.Text = "";
//validate empty username and password
if (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtPass.Text))
{
lblErrorLogin.Text = "Please enter username and password correctly.";
return;
}
BasicFormAuthentication formAuth = new BasicFormAuthentication();
bool isAuthenticated;
//check if the user input is correct
isAuthenticated = formAuth.IsAuthenticated(txtUserName.Text, txtPass.Text);
if (isAuthenticated == true)
{
//if authenticated then create a user session for the username
formAuth.CreateUserSession(txtUserName.Text, IsCookiePersistent);
//Session User name is saved on the separate session variable
Session["UserName"] = txtUserName.Text;
//Access as set
Access.SetModuleAccess();
//Log the login time of the user
User.DataCtrl.UserLog();
//InsertDIDMonitoringParameters(); //robert modification 20121220
if (this.ReturnURL == null) //this.ReturnURL = FormsAuthentication.GetRedirectUrl(txtUserName.Text, this.IsCookiePersistent);
{
//if the user has a remind password flag up
//then the next page will pop up the reminder
MessageHandling.Message = Access.CurrentUser.GetReminders();
//all logins will redirect to the default page and the default page
//the default page is a dummy page that will redirect then to their homepage
//if session is null or expired they will be returned to the login page
Response.Redirect("~/Default.aspx");
}
}
else
{
//log in failed response
switch (formAuth.LoginFailedCode)
{
case 0:
lblErrorLogin.Text = "Logon failed: Wrong username or password.";
break;
case 1:
lblErrorLogin.Text = "Logon failed: User does not exist!";
break;
case 2:
lblErrorLogin.Text = "Logon failed: User is deactivated!";
break;
case 3:
lblErrorLogin.Text = "Logon failed: User is locked due to max password tries!";
break;
default:
lblErrorLogin.Text = "Logon failed: Authentication Error!";
break;
}
}
if (LoginClick != null) LoginClick(this, EventArgs.Empty);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.StackTrace);
lblErrorLogin.Text = "Internal Error, Contact Gjenesis Admins." + ex.Message;
//lblErrorLogin.Text = ex.Message;
return;
}
尽可能地我不想更改此代码,因为之前我甚至在开始使用此系统之前我没有遇到过这种错误,然后有一天网站开始执行此操作。我们的生产网站甚至我们的开发都很好我只在我的本地代码上体验这一点,我在构建IIS或托管在我的本地IIS上运行该站点。