2014-04-01 39 views
0

我是新来的asp.net,并试图为我的项目制作一个页面,但是当我运行此页面时出现错误,此页面有直接循环。请提供给我任何解决方案此页面在asp.net中有重定向循环错误

这是我的代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using idw.DBhelper; 
using System.Web.Security; 


namespace idw.realitycheck 
{ 
     public partial class SignIn : System.Web.UI.UserControl 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 


     } 
    public void LoginButton_onclick(object sender, System.EventArgs e) 
    { 
     idwUser accountSystem = new idwUser(); 
     string userId = accountSystem.Login(email.Text,password.Text); 

     if ((userId != null) & !string.IsNullOrEmpty(userId)) 
     { 
      // Use security system to set the UserID within a client-side Cookie 
      FormsAuthentication.SetAuthCookie(userId, RememberCheckbox.Checked); 
      // Redirect browser back to originating page 
      FormsAuthentication.RedirectFromLoginPage(userId, false); 
     } 
     else 
     { 
      Message.Text = "Login Failed!"; 
     } 
    } 
} 
} 

回答

0

它看起来像你需要在web.config中forms元件,配置一些额外的参数。尝试<forms name="name" loginUrl="URL" defaultUrl="URL" protection="All"/>其中defaultUrlFormsAuthentication.RedirectFromLoginPage将使用的登录页查询字符串中不存在ReturnUrl。请注意,您不能设置loginUrldefaultUrl都指向login.aspx,并且可能导致重定向循环。

相关问题