SimpleUser
SimpleUser

Reputation: 1351

How to redirect user to a default error page when exception is raised in application_start?

Is there a way to redirect the user to an error page (view) when an exception is raised in application_start method of global.asax? I get a Request object is null message when I try to do a redirect. How would i handle this? I have to raise the exception if certain conditions are not met and I want the user to go to a specific View.
My application is MVC3 based, btw.

Thanks

Upvotes: 1

Views: 2224

Answers (2)

Oybek
Oybek

Reputation: 7243

You can refer this page.

The thing you are trying to do is possible via Web.config Just show what page to load when http error 500 occurs.

Edit

Sorry gave wrong url

Upvotes: 0

SLaks
SLaks

Reputation: 887469

Application_Start happens before ASP.Net starts processing the request.

You could set a global static flag to indicate the error condition, then handle BeginRequest and check the flag and redirect.

Upvotes: 1

Related Questions