Is it possible to redirect to a page, in UserSignInHandler?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
11/19/2012 11:36:43 AM
Gravatar
Total Posts 192

Is it possible to redirect to a page, in UserSignInHandler?

Is it possible to redirect to a page, in UserSignInHandler?

there is no access to the HttpContext Object.

11/19/2012 12:09:05 PM
Gravatar
Total Posts 2183

Re: Is it possible to redirect to a page, in UserSignInHandler?

Hi,

Yes, this is possible. Here's the code from a UserSignInHandler EventHandler that I created a while back that does this exact thing. Relevant code in bold.

public class RedirectToUserPageOnLogin : UserSignInHandlerProvider
{
private static readonly ILog log = LogManager.GetLogger(typeof(CreateUserPage));
private SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
private SiteUser siteUser = null;
public RedirectToUserPageOnLogin()
{ }


public override void UserSignInEventHandler(object sender, UserSignInEventArgs e)
{
if (e == null) return;
if (e.SiteUser == null) return;

siteUser = e.SiteUser;

if (siteUser.WebSiteUrl != string.Empty)
{
//SiteUtils.RedirectToUrl(siteUser.WebSiteUrl);
HttpContext.Current.Response.Redirect(SiteUtils.GetNavigationSiteRoot() + siteUser.WebSiteUrl, true);
}

}
}

I stored the redirect URL in the WebSiteUrl property of the SiteUser object. I did that only because it was an easy place to store and retrieve it.

Hope this helps,
Joe D.

11/21/2012 1:57:22 PM
Gravatar
Total Posts 192

Re: Is it possible to redirect to a page, in UserSignInHandler?

Thanks.

I had a problem of not being able to access HttpContext Object.

and the problem was In the class library I hadn't referenced System.Web.

You must sign in to post in the forums. This thread is closed to new posts.