[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 2010-04-09
2
Medium Priority
?
933 Views
Last Modified: 2013-11-26
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.

0
Comment
Question by:csalle01
  • 2
2 Comments
 

Author Comment

by:csalle01
ID: 30218277
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
 

Accepted Solution

by:
csalle01 earned 0 total points
ID: 30224477
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question