Hi,
(Sorry if this is in the wrong forum, but I couldn't find a better one.)
I have some code which attempts to create and write to a log file in a subdirectory of my website (shown below). If I put the first call to this code in the Page_Load() event of Default.aspx, it works fine every time. If, however, I make the first call to this code inside the Global.asax Application_Start() event, I get an access denied exception from .NET, even though the path displayed in the exception message is correct and is a subdirectory of my site root.
Has anyone encountered anything like this? It is as if the code running from Application_Start() has a more limited set of permissions than code running later.
Kind wishes ~ Patrick
string s = string.Format( "{0}logs\\Log.txt", HttpRuntime.AppDomainAppPath );
using( StreamWriter writer = new StreamWriter( s, true ) )
{
string logEntry = DateTime.Now.ToString() + ": " + formattedMessage;
writer.WriteLine( logEntry );
writer.Flush();
}