Application_Start not behaving correctly in ASP.Net 4.0 Application

妖精的绣舞 提交于 2019-12-25 04:04:01

问题


I'm stumped. I ran through all the recommendations on StackOverflow and Google... no joy.

My Application_Start method is not behaving correctly in my ASP.Net 4.0 application. I can set Application variables, but not call my logging method.

I can set variables:

Application["appStartDT"] = DateTime.Now.ToString();

But my logging method is not called:

Utilities.writeLog("Application started at: " + System.DateTime.Now.ToString(), 4);

This happened about the time I switched from the internal IIS server in VWDE 2010 to IIS 7.5 (On Windows 7), though I'm not 100% it's related (had to switch, as I was using virtual directories).

[Post Script Edit: I switched to project back to "Use Visual Studio Development Server" and my Application_Start method fired and executed my logging method. I need to use IIS. Any suggestion on what IIS setting I am overlooking?]

Any suggestions would be helpful.

Respectfully,

Ray


回答1:


I think one difference with switching to IIS is that the IIS process that your website is running under will now be the [local machine]\Network Service account. I am assuming that your Utilities.writeLog method is writing something out to a file. If that in fact is the case, then you should check that the Network Service account has read/write privileges to the file and folder where you are logging. I have experienced this same issue with log4Net logging output to a file and when I gave the Network Service account access to the folder/file I was logging to, the issue went away.



来源:https://stackoverflow.com/questions/6351608/application-start-not-behaving-correctly-in-asp-net-4-0-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!