Using profile in Global.asax
Posted on 2006-05-26
I am hoping this is an easy 500 points for someone. I have an intranet application which is pulling the display name from the currently logged in user and all of that works fine. What I want to do is store the information in the users profile class. I was able to store this in ther session object but want to use the new profile class since it is strongly typed and new & pretty. I have followed all of the examples i can find and it works except when I try to set the value in the global.asax.
Profile.UserDisplayName = "GeorgeTest";
This works fine is i use it in an aspx page but gives me an error in the global.asax.
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
at ASP.global_asax.Session_Start(Object sender, EventArgs e) in c:\Documents and Settings\dukeg\My Documents\Visual Studio 2005\WebSites\JanetsApp\Global.asax:line 46
at System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e)
at System.Web.SessionState.SessionStateModule.OnStart(EventArgs e)
at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)