ASP.NET App Writing to Event Log on Server

O

orp

We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles
getting the ASP.NET app. to write to the event log when accessing the web
site from a separate client computer.

Here's some details:

Server and client computers both in the same workgroup
Logged into server as local Administrator
Logged into client as a local user that is only in the Users group on the
client computer
The local user on the client is also defined as a local user on the server
with same name and password (and only in the Users group on the server too)
Server is Windows Server 2003 running IIS 6.0
Client is Windows XP Professional
ASP.NET 2.0 (C#) web site - intranet only, not a public Internet web site


Web.config snippet
<system.web>
<authentication mode="Windows"/>
<identity impersonate="true"/>
</system.web>



..aspx code-behind code snippet
string exceptionInfo = "Testing WriteToEventLog";
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Log = "Application";
log.Source = "Application";

try
{
// EXCEPTION happens here
log.WriteEntry(exceptionInfo,
System.Diagnostics.EventLogEntryType.Error);
}
finally
{
log.Close();
log.Dispose();
}


The exception details are: System.ComponentModel.Win32Exception: Access is
denied (Cannot open log for source 'Application'. You may not have write
access.)

From the client computer, I can navigate to the site and do whatever without
any problems. But, when the site tries to write to the event log on the
server for the session started by the client in the scenario described
above, it fails.

Basically, this is supposed to be an exception notification thing.


What's wrong? Am I missing something? How can I make the above scenario
work?


Thanks.
 
K

Kevin Spencer

What account is your ASP.Net app running under? It is that account that
doesn't have permission.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
O

orp

Thanks. I'm not sure what account my ASP.NET app is running under. How can
I tell?

I can tell you this, however. It works fine if I log into the client as a
user in the client's local Administrators group (the user is also in the
Administrators group on the server).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top