Tuesday, July 5, 2011

ASP.NET: Visual Studio 2010 with IIS Express 7.5

Context:

Windows XP
Visual Studio 2010
ASP.NET
IIS 5.1
IIS Express 7.5

Problem:

I wanted to run my ASP web site from Visual Studio 2010 and access the web site from another computer.  In my case, it's a Windows XP running in VirtualBox.

Visual Studio 2010 came with a development server, you could run your ASP pages directly from it.  However, it is restricted.  You can only access it locally, meaning that you can only access it on the same machine that Visual Studio 2010 is running.

Since I wanted to access it from a different machine,  I tried publishing my web site to IIS 5.1.  After registering ASP.NET Framework 2 with it to work with aspx and asmx, I tried to access it from a different machine, and I got this in my event log:

Failed to execute request because the App-Domain could not be created. Error: 0x80131902 


Failed to initialize the AppDomain:/LM/W3SVC/1/ROOT


Exception: System.Configuration.ConfigurationErrorsException


Message: Exception of type 'System.Configuration.ConfigurationErrorsException' was thrown.


StackTrace:    at System.Web.Configuration.ErrorRuntimeConfig.ErrorConfigRecord.System.Configuration.Internal.IInternalConfigRecord.GetLkgSection(String configKey)
   at System.Web.Configuration.RuntimeConfigLKG.GetSectionObject(String sectionName)
   at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
   at System.Web.Configuration.RuntimeConfig.get_HostingEnvironment()
   at System.Web.Hosting.HostingEnvironment.StartMonitoringForIdleTimeout()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

Solution:

For a while, I didn't know what the problem was.  I searched the Internet and found different solutions, such as trying to grant security access to the wwwroot and whatnot.  I tried it all, but it didn't work for me.  It was frustrating.


After some research, I found out that I could get what I wanted through getting Visual Studio 2010 SP1 and IIS Express 7.5.  After installing the SP1 and IIS Express, to tell Visual Studio to use IIS Express instead of the default Visual Studio Development Server, you right click on your web project and choose "Use IIS Express..."  That's it.  I did get it to work how I wanted it to.

P.S.  I've been a Java guy for a long time.  Recently, I started working on this project which has .NET stuff, so I just started digging into .NET for a couple of weeks now.

No comments:

Post a Comment