Chris Barlow
Chris Barlow

Reputation: 3314

ASP.NET MVC3 Debugging Application_Start

I am trying to deploy my first MVC3 application to a server running IIS-7.5. I've got the thing up and running, but I'm having some trouble with my debugging methods. I use a proprietary debugging construct that works just fine when I run the application locally (using the built in "IIS Express" module and Visual Studio) - but when I deploy to the server, I don't even get my debug file created, much less printed to.

The debugging file is created in the Application_Start event, so I put an event log stamping in the Application_Start event and ran the application locally and on the server, just to see if the event is getting fired. My event logs locally were stamped to as intended, but the event logs on the server are bare of any new stamping. What's going on here?

protected void Application_Start()
  {
     AreaRegistration.RegisterAllAreas();

//This is just some code that calls to another module I wrote to easily stamp to the Event logs - it works, trust me
     EventLogging.Initialize();
     EventLogging.WriteEventLog("Application Start Called Successfully");
  }

Upvotes: 5

Views: 1745

Answers (2)

CtrlDot
CtrlDot

Reputation: 2513

IIS 7.5 uses virtual accounts for the application pools.

See App Pool Identities. Make sure the specific app pool identity has access to the appropriate folder to read/write.

Upvotes: 1

JaredPar
JaredPar

Reputation: 754545

I believe the problem you're running into is the IIS process is run under the Network Service account. By default this account only has read and execute permissions to the IIS root folder. Hence any attempts to write to the local file system will fail.

To make this work you'll need to give the Network Service account explicit write access to the file in question. This can be done via Windows Explorer.

  • Right Click on the file and select properties
  • Go to the security tab
  • Add write access for the Network Service account

Upvotes: 2

Related Questions