---
title: "How can I tell if Request/Response is available in Application_Error?"  
description: "How can I tell if Request/Response is available in Application_Error?"  
author: "Anonymous User"  
published: 2015-06-01  
updated: 2015-06-01  
canonical: https://www.mindstick.com/forum/23276/how-can-i-tell-if-request-response-is-available-in-application_error  
category: ".net"  
tags: ["c#", "asp.net", "error"]  
reading_time: 1 minute  

---

# How can I tell if Request/Response is available in Application_Error?

If Application_Error is triggered by an [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) in the application. RouteConfigor BundleConfig.

how can you [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) the [Request](https://www.mindstick.com/blog/255/post-get-and-request-function-in-php)/[Response](https://www.mindstick.com/forum/12719/how-to-make-response-write-display-special-character-like-lt-gt) is available?

Response.Clear throws System.Web.HttpException with [additional information](https://www.mindstick.com/forum/160484/error-failed-to-launch-debug-adapter-additional-information-may-be-available-in-the-output-window) Response is not available in this context.

```
void Application_Error(object sender, EventArgs e){    //Log error    Log.Error(e);    //Clear    Response.Clear();   
Server.ClearError();    //Redirect   
Response.Redirect("~/Error");}
```

## Replies

### Reply by Anonymous User

You want to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) whether it is HttpException.

```
protected void Application_Error(Object sender, EventArgs e){    var exception =Server.GetLastError();    // Log error   
LogException(exception);    var httpException= exception as HttpException;    if (httpException!= null)    {       
Response.Clear();       
Server.ClearError();       
Response.TrySkipIisCustomErrors = true;       
Response.Redirect("~/Error");    }}
```


---

Original Source: https://www.mindstick.com/forum/23276/how-can-i-tell-if-request-response-is-available-in-application_error

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
