ASP.NET MVC Works in Local Visual Studio Server NullReferenceException on IIS

I am developing a small asp.net mvc intranet application for our company.  Right now the home page will get the Windows username from the windows logged on user and make a call to our active directory based on that username to get more detailed info about the user (email, ect.)

Everything works great on my local Visual Studio 2008 server.  But when I deploy all the files to my IIS 6.0 server I get the following:

[NullReferenceException: Object reference not set to an instance of an object.]
   STPIntranet.MvcApplication.Session_Start() in C:\Documents and Settings\csallemi\My Documents\Visual Studio 2008\Projects\STPIntranet\STPIntranet\Global.asax.cs:50

[TargetInvocationException: Exception has been thrown by the target of an invocation.]


   System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +350
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
   System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +42
   System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e) +8779824
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +237
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +504
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +66
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

It is failed in my Global.asax.cs file where I try to populate a custom User object (has a username and email property). In line 50 where the error is occuring I make a call to a class called SecurityUtil to get the theusername from WindowsIdentity.GetCurrent(); and get the email by making a call into our active directory.

I almost want to say that the necessary libraries are not getting added in either my project dll or web.config file because of the null pointer.

Please help. I'm running out of ideas.

csalle01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

csalle01Author Commented:
Another thing I am concerned with is the error line :
C:\Documents and Settings\csallemi\My Documents\Visual Studio 2008\Projects\STPIntranet\STPIntranet\Global.asax.cs:50 is pointing to my local file structure and not my local iis directory path.
0
csalle01Author Commented:
I figured out my issue.  I needed to use HttpContext.Current.User.Identity since Window.CurrentIndentity returns NetworkService in IIS6 and not the current user.

thanks
Chris
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.