Blogengine Login.aspx

Aug 29, 2009 at 8:27 PM

I would like to change the destination url for the login1 control in the BE Login.aspx.  Basically I have it working fine, but I want to change the success login desination url to be something other then default.aspx.  I have created login pages in the past and all you have to do it modify the control properties to point to the destinatin URL of your choosing.  This is not available through the login.aspx page in BE app.  I have created my own theme that integrates a full site and I would like a successfull login to autmatically land on one of my newly created pages (home.aspx)  I have looked through the BE applicaiton and can't change the login control directly, so it must be coded somewhere else. 

Sep 2, 2009 at 9:43 PM

Hi there,

Please take a look at code behind file of login.aspx (i.e. login.aspx.cs). It contains the function that verifies and redirects the user to another page once the user is authenticated.

/// <summary>
/// Handles the LoggedIn event of the Login1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void Login1_LoggedIn(object sender, EventArgs e)
{
	if (!Roles.IsUserInRole(Login1.UserName, BlogEngine.Core.BlogSettings.Instance.AdministratorRole))
		Response.Redirect(BlogEngine.Core.Utils.RelativeWebRoot, true);
}

Replace the "BlogEngine.Core.Utils.RelativeWebRoot(i.e. default.aspx)" with your custom page URL.

 

Hope this helps.

Sep 4, 2009 at 11:22 PM
Edited Sep 4, 2009 at 11:24 PM

thanks for the reply.  Unfortunately it is still directing me to the default.aspx page.  Here is what I currently have in the code behind for login.aspx.  I have tried this with just "home.aspx"  rather then ~/home.aspx and it redirects to the default.aspx everytime. 

 

void Login1_LoggedIn(object sender, EventArgs e)

 

if (!Roles.IsUserInRole(Login1.UserName, BlogEngine.Core.BlogSettings.Instance.AdministratorRole))

Response.Redirect(

"~/home.aspx");

Sep 4, 2009 at 11:39 PM

thats because ! (Symbol represting Not operator) is preceding the test. That means, the above test checks whether the user is in Administrator role or not(i wonder why it's used like that). If the user is not in Administrator role, the user will be redirected to the custom defined page. If you don't want that comparison to exist, just use this code.

 

/// <summary>
/// Handles the LoggedIn event of the Login1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void Login1_LoggedIn(object sender, EventArgs e)
{
	Response.Redirect(BlogEngine.Core.Utils.RelativeWebRoot, true);
}

That should do your work.

 

 

 

Sep 5, 2009 at 3:33 AM

thank you, thank you   That did the trick!