This is a migrated thread and some comments may be shown as answers.

Telerik Login Web form

0 Answers 387 Views
Code Generation
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ashoo Sharda
Top achievements
Rank 1
Ashoo Sharda asked on 19 Apr 2010, 08:33 PM
I used the just code to add a login webform. I am using custom membership provider and a custom role provider. The problem is that the User.Identity.Name for some reason doesn't get set and is always blank and hence I am unable to use the FormsAuthetication.Authenticate(user, passwd) method as it ivaluates to false.

While creating the login page I did set it to use customproviders. We had comment out the lines and call the membership.validateUser to make it work.

Please advise what I shd do so I can use the FormAuthentication class. Here is the .cs code for the login page

public

 

partial class LoginRadWindow : System.Web.UI.Page

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

if (IsPostBack && Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))

 

{

 

//if (User.Identity.IsAuthenticated)

 

 

RadScriptManager.RegisterStartupScript(this, this.GetType(), "closeDialog", "closeDialog();", true);

 

}

}

 

protected void Login_OnClick(object sender, EventArgs e)

 

{

 

//if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))

 

 

if (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))

 

{

Session[

"User"] = UsernameTextbox.Text;

 

 

RadScriptManager.RegisterStartupScript(this, this.GetType(), "closeDialog", "closeDialog();", true);

 

 

RadScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "window.top.location.href ='" + FormsAuthentication.GetRedirectUrl(UsernameTextbox.Text, false) + "';", true);

 

 

//FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, false);

 

}

 

else

 

Msg.Text =

"Login failed. Please check your user name and password and try again.";

 

}

}

Tags
Code Generation
Asked by
Ashoo Sharda
Top achievements
Rank 1
Share this question
or