The title is lengthy, but it explains almost all of the relevant details of my issue.
I have forms authentication setup and I am using web.config for my membership providers/connection strings to use Active Directory as an authentication authority.
This means that my login.aspx.cs (code behind) is pretty minimal.
My goal is to pass the login.username and login.password values through to the next page (to the default.aspx) page after authentication happens. (So I want to have access to the values that my users enter for username and password on the Default.aspx page)
the reason for this is to pass them again into a different authentication mechanism that is only available on the default.aspx page (and unfortuneatly a cookie won't work).
I thought at first that I could access the values directly, and this works on the page (i added a button that just shows the values, and have no problem with it). But I need to to happen with the user authenticates (so it is seemless).
I first tried the login1_Authenticate event to add the values to a session, which didn't work.
I then thought I needed to access the values before authentication, so I moved the session variables into the LoggingIn event which didn't work either.
So I tried to use the PreviousPage property to access public variables that get set during the LoggingIn event, but that didn't work either so I am thinking that my LoggingIn event isn't actually fireing.
this is my codebehind for login.aspx and shows my attempt at both a session variable and a PreviousPage variable.
Any suggestion on this could help me tremendously. Remember: Active Director based forms authentication trying to pass login.password and login.username to the default.aspx page upon authentication.
john.gleason
Member
92 Points
33 Posts
Unable to acess Login.username or Login.password properties from LoggingIn method of asp:Login co...
Feb 21, 2013 07:05 PM|LINK
The title is lengthy, but it explains almost all of the relevant details of my issue.
I have forms authentication setup and I am using web.config for my membership providers/connection strings to use Active Directory as an authentication authority.
This means that my login.aspx.cs (code behind) is pretty minimal.
My goal is to pass the login.username and login.password values through to the next page (to the default.aspx) page after authentication happens. (So I want to have access to the values that my users enter for username and password on the Default.aspx page) the reason for this is to pass them again into a different authentication mechanism that is only available on the default.aspx page (and unfortuneatly a cookie won't work).
I thought at first that I could access the values directly, and this works on the page (i added a button that just shows the values, and have no problem with it). But I need to to happen with the user authenticates (so it is seemless).
I first tried the login1_Authenticate event to add the values to a session, which didn't work.
I then thought I needed to access the values before authentication, so I moved the session variables into the LoggingIn event which didn't work either.
So I tried to use the PreviousPage property to access public variables that get set during the LoggingIn event, but that didn't work either so I am thinking that my LoggingIn event isn't actually fireing.
this is my codebehind for login.aspx and shows my attempt at both a session variable and a PreviousPage variable.
public partial class login : System.Web.UI.Page { public string storedpassword; public string storedusername; protected void Page_Load(object sender, EventArgs e) { } protected void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e) { storedusername = frm_login.UserName.ToString(); storedpassword = frm_login.Password.ToString(); Session["id"] = HttpContext.Current.Session.SessionID; Session["username"] = frm_login.UserName.ToString(); Session["password"] = frm_login.Password.ToString(); } }And here is my aspx code for the login control:
<asp:Login ID="frm_login" align="center" runat="server" DestinationPageUrl="~/Default.aspx" DisplayRememberMe="False" BackColor="#EFF3FB"BorderColor="#B5C7DE" BorderPadding="4"
BorderStyle="Solid"
BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#333333"
loggingin="OnLoggingIn" TitleText="Enter your Username and Password"
VisibleWhenLoggedIn="False" UserNameLabelText="Username:"
Height="105px"
Width="363px" > <InstructionTextStyle Font-Italic="True" ForeColor="Black" /> <LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" /> <TextBoxStyle Font-Size="Large" /> <TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White" /> </asp:Login>
Any suggestion on this could help me tremendously. Remember: Active Director based forms authentication trying to pass login.password and login.username to the default.aspx page upon authentication.
Thanks!
john.gleason
Member
92 Points
33 Posts
Re: Unable to acess Login.username or Login.password properties from LoggingIn method of asp:Logi...
Feb 22, 2013 12:00 AM|LINK
I got it by setting a session variable (and tested it as working with a cookie as well) in the LoginButton_Click event:
The previouspage directive did not work it caused a null reference exception.
public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e) { } protected void LoginButton_Click(object sender, EventArgs e) { Session["username"] = frm_login.UserName.ToString(); Session["password"] = frm_login.Password.ToString(); //Response.Cookies["Password"].Value = frm_login.Password.ToString(); } }Pengzhen Son...
Star
8208 Points
846 Posts
Microsoft
Re: Unable to acess Login.username or Login.password properties from LoggingIn method of asp:Logi...
Feb 27, 2013 02:08 AM|LINK
Hi,
We are happy that your issue has been resolved. And Thanks for your sharing solution.
Best Regards,
Pengzhen
Feedback to us
Develop and promote your apps in Windows Store