2013-05-10 65 views
1

我设置登录了在C#RedirectFromLoginPage - 资源无法找到错误

if (TextBox1.Text == System.Convert.ToString(row["Username"]) && 
     (TextBox2.Text == System.Convert.ToString(row["Password"]))) 
      System.Web.Security.FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false); 

    else 
     Label1.Text = "Invalid Username/Password"; //If incorrect show this label 

一旦用户输入正确的细节,我得到一个网页说The resource cannot be found我的问题是在哪里我设置的页面,它应该重定向到?

到目前为止,我的web.config看起来像这样

<authentication mode="Forms"> 
<forms> 

</forms> 

我连接到一个数据库,以获得正确的信息,本节所有作品它只是页面的重定向。

回答

4

RedirectFromLoginPage方法重定向到在returnUrl查询字符串参数指定的页面,或作为备用,在你的web.config中指定的defaultUrl属性:

<authentication mode="Forms"> 
    <forms loginUrl="member_login.aspx" 
    defaultUrl="index.aspx" /> 
</authentication> 

这里看到更多的信息:

RedirectFromLogin:http://msdn.microsoft.com/en-us/library/ka5ffkce.aspx

DefaultUrl:http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.defaulturl.aspx