Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:46:29+00:00 2026-05-24T19:46:29+00:00

I created protected void Application_Error(object sender, EventArgs e) { if (Context.Handler is IRequiresSessionState ||

  • 0

I created

protected void Application_Error(object sender, EventArgs e)
{
   if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState)
   {
      try
      {
         var httpContext = HttpContext.Current;
         Exception exception = httpContext.Server.GetLastError();

         if (exception is HttpRequestValidationException)
         {
            httpContext.Response.Clear();
            var logLoggerService = new LogLoggerService();
            logLoggerService.Error("ValidationException", exception);
            WriteErrorResponse(exception.Message);
         }
         else
         {
            httpContext.Response.Clear();
            var logLoggerService = new LogLoggerService();

            logLoggerService.Error(exception);
            WriteErrorResponse(exception.Message);
         }
     }
     catch
     {
        var httpContext = HttpContext.Current;
        httpContext.Response.Clear();
     }
  }
}

I found that when error occurred on server, this function is not call. But when I am in debug mode, the Application_Error is called.

Why this does not work on server? Maybe problem with IIS or with .NET 4.0 on server?

On server I have:

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 15-8-2011 8:25:26
Event time (UTC): 15-8-2011 6:25:26
Event ID: ae3cad590adc43c3803410023cccb6b0
Event sequence: 4
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/11/ROOT-1-129578631124796958
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\TestnaAplikacijaZaLog\
Machine name: SRJ1-SRV-01

Process information:
Process ID: 6644
Process name: w3wp.exe
Account name: IIS APPPOOL\TestnaAplikacijaZaLog

Exception information:
Exception type: HttpException
Exception message: Response is not available in this context.
at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

Response is not available in this context.
at System.Web.HttpContext.get_Response()
at LogiranjeGresaka.MvcApplication.Application_Start() in c:\users\esmira\documents\visual studio 2010\Projects\LogiranjeGresaka\LogiranjeGresaka\Global.asax.cs:line 46

Request information:
Request URL: http://192.168.0.100:2227/Home/Index
Request path: /Home/Index
User host address: 192.168.0.103
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\TestnaAplikacijaZaLog

Thread information:
Thread ID: 7
Thread account name: IIS APPPOOL\TestnaAplikacijaZaLog
Is impersonating: False
Stack trace: at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

Custom event details:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:46:29+00:00Added an answer on May 24, 2026 at 7:46 pm

    I solve problem with adding

    <system.web>
      <customErrors mode="Off" />
    </system.web>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the aspx.cs file for my web application: protected void Button1_Click(object sender, EventArgs
protected void Application_BeginRequest(object sender, EventArgs e) { const int maxFileSizeKBytes = 10240; //10 MB
I created a protected folder on my ASP.NET site with the ASP.NET Configuration tool.
I created a script in ASP.NET which list the files from specified folder. protected
I've created an event handler that simply returns a list of objects that I
I just want to understand why I cannot create a protected enum on C#?
I'd like to create an internal auto-property: internal bool IP { get; protected internal
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.