ASP.NET App Writing to Event Log on Server

Discussion in 'ASP .Net' started by orp, May 5, 2006.

  1. orp

    orp Guest

    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.
     
    orp, May 5, 2006
    #1
    1. Advertising

  2. 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.

    "orp" <> wrote in message
    news:%...
    > 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.
    >
    >
    >
     
    Kevin Spencer, May 5, 2006
    #2
    1. Advertising

  3. orp

    orp Guest

    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).


    "Kevin Spencer" <> wrote in message
    news:uyY2j$...
    > 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.
    >
    > "orp" <> wrote in message
    > news:%...
    > > 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.
    > >
    > >
    > >

    >
    >
     
    orp, May 5, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik_the_boss
    Replies:
    0
    Views:
    2,715
    Henrik_the_boss
    Nov 5, 2003
  2. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,415
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  3. rekaeps
    Replies:
    6
    Views:
    665
    Jeff Dillon
    May 5, 2006
  4. Tom Wingert
    Replies:
    0
    Views:
    377
    Tom Wingert
    Jan 12, 2006
  5. Replies:
    0
    Views:
    1,421
Loading...

Share This Page