2014-04-01 38 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,並且可能導致重定向循環。

相關問題