lance
lance

Reputation: 16342

Application_PreRequestHandlerExecute: null HttpContext.Current?

Is it safe to always assume that HttpContext.Current will be non-null in Application_PreRequestHandlerExecute?

EDIT: Assuming ASP.NET webforms (not MVC).

Upvotes: 1

Views: 1156

Answers (2)

FiveTools
FiveTools

Reputation: 6030

There has to be a current httpcontext object if the app is running.

Upvotes: 1

womp
womp

Reputation: 116977

Yes, unless you're running the code outside of the asp.net pipeline (in unit tests or some such).

The HttpApplication is handed an HttpContext upon creation.

Upvotes: 1

Related Questions