Working, coding and debugging within Visual Studio environment is very practical and mostly error free. But sooner or later you will need to push your application to a production environment (third-party hosting usually). Some development environments are harder than others. Some will have more instructions than others. My environment is ASP.NET MVC S#arp Framework using Nhibernate in IIS 7.0.
I setup a virtual directory that maps to my Publish directory. The setup I have currently mimics the one in my hosting environment. These are the steps I took along with the error messages I got.
Once my virtual directory was created in IIS7 I decided to publish and test my application. I encountered the first error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.PipelineStepManager.ResumeSteps(Exception error) +929
AsyncCallback cb) +91
HttpContext context) +508
The problem here is the NHibernate initialization happening in Application_Start(). Not sure if a fix has been checked-in yet but the solution for me was to use IIS7 in Classic Mode.
From IIS Manager. Select the virtual directory. Select “Advanced Settings”, change Application Pool from “DefaultAppPool” (Integrated Mode) to “Classic .NET AppPool”.
Now that changes makes the next one a requirement. If you run your application now, the message will be gone and you will most likely be able to see your home page but once you try to navigate from page to page you will get a 404 error message. The next step is to add a “Wildcard Script Map”.
Again, from IIS Manager, open “Handler Mappings”. Then “Add Wildcard Script Map…”, browse to the executable “aspnet_isapi.dll”, located in the Windows directory, NetFramework 2.0.50727. You can name it “ASP.NET MVC”.
After that your site should be up and running in your local machine and migration to your hosting environment should be a bit easier