Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Nov 09, 2011 06:43 PM|LINK
I recently wrote a method that tracks unexpected errors. This method is called in the global.asax file in the Application_Error event. I pass the .Net Profile object to this method. For some reason that I have yet to determine, from time to time, some
of the fields in the Profile object have null values when referenced in the Application_Error event. This is an asp.net 2.0 intranet application where all users have to log in.
The profile object and its properties has always been available to every one of my pages. I never had a problem with it. For some reason, the properties lose their value after the user logs in and an unexpected error happens. To compond the problem, the
profile properties sometimes have values and are sometimes null.
I have no clue as to why this is happening. Could this have something to do with the page life cycle? In other words, maybe the error happens before the page event that gives you access to the profile? Does anyone know what event that would be?
Any help would be much appreciated. Below are snippets from
Thanks so much. This is driving me crazy.
My web.config has the following code.
<profile enabled="true" defaultProvider="SqlProvider">
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="CompanyNameConnectionString"/>
<add name="UserID" type="int"/>
<add name="LocationCode" type="String"/>
<add name="LocationDescription" type="String"/>
<add name="URL" type="String"/>
<add name="PageTitle" type="String"/>
<add name="PermissionCode" type="String"/>
<add name="PermissionDescription" type="String"/>
<add name="Message" type="String"/>
<add name="DepartmentCode" type="int"/>
<add name="MenuID" type="int"/>
When the user logs in, I run the following code in the LoggedIn event to load the profile.
ProfileCommon p = Profile.GetProfile(UserLogin.UserName);
if (p == null)
throw new Exception("Profile was Not Created for " + UserLogin.UserName);
p.UserID = DGUser.UserID;
p.LocationCode = location.LocationCode;
p.LocationDescription = location.Description;
p.DepartmentCode = DGUser.DepartmentCodes.DepartmentCode;
p.MenuID = Globals.MenuItems.DefaultPage;
void Application_Error(object sender, EventArgs e)
The Error Handler Service
public static void HandleUnExpectedError(ProfileCommon profile)