ASP.NET MVC3 调试 Application_Start
我正在尝试将我的第一个 MVC3 应用程序部署到运行 IIS-7.5 的服务器。我已经启动并运行了它,但是我的调试方法遇到了一些问题。我使用专有的调试结构,当我在本地运行应用程序时(使用内置的“IIS Express”模块和 Visual Studio),它工作得很好 - 但是当我部署到服务器时,我什至没有创建我的调试文件,更少打印到。
调试文件是在 Application_Start 事件中创建的,因此我在 Application_Start 事件中添加了事件日志标记,并在本地和服务器上运行应用程序,只是为了查看该事件是否被触发。我在本地的事件日志已按预期标记,但服务器上的事件日志没有任何新标记。这是怎么回事?
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");
}
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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您遇到的问题是 IIS 进程在网络服务帐户下运行。默认情况下,此帐户仅具有 IIS 根文件夹的读取和执行权限。因此,任何写入本地文件系统的尝试都将失败。
要实现此功能,您需要向网络服务帐户授予对相关文件的显式写入权限。这可以通过 Windows 资源管理器完成。
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.
IIS 7.5 对应用程序池使用虚拟帐户。
请参阅应用程序池标识。确保特定应用程序池标识有权访问适当的文件夹以进行读/写。
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.