Tuesday, April 5, 2011

Run custom code on login

I’ve used the asp.net login control on my sharepoint custom master page. All works well and I can login to my site without problems.

However I’d like to run some code once the user has logged, or alternatively perform a redirect based on the user’s role.

Has anyone does this type of thing before?

From stackoverflow
  • You can test roles programmatically through User.IsInRole

    EDIT: on redirect from the ASP.NET login control, check for the forms authenication token and run your custom code if the token is present.

  • OK cool, but do you know of any way i can attach my own code to run when the user clicks the 'log-in' button?

  • The Login control (System.Web.UI.WebControls.Login) has an event LoggedIn (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.loggedin.aspx). Just subscribe to it and place your code in the handler. I haven't worked with sharepoint, I'm talking from an ASP.NET viewpoint here.

    Rob : doh! think i made that more difficult than it need to be, thanks for you help :-)

0 comments:

Post a Comment