I set custom error enable in Web.config:
<customErrors mode="On"/>
and, in Application_Start, put these:
protected void Application_Error(object sender, EventArgs e) {
var ex = Server.GetLastError().GetBaseException();
var routeData = new RouteData();
if (ex.GetType() == typeof(HttpException)) {
var httpException = (HttpException)ex;
var code = httpException.GetHttpCode();
routeData.Values.Add("status", code);
} else {
routeData.Values.Add("status", -1);
}
routeData.Values.Add("action", "Index");
routeData.Values.Add("controller", "Error");
routeData.Values.Add("error", ex);
IController errorController = new Kavand.Web.Controllers.ErrorController();
errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
}
also I create an error controller like this:
public class ErrorController : Kavand.Web.Mvc.Kontroller
{
public ActionResult Index(int status, Exception error) {
Response.StatusCode = status;
HttpStatusCode statuscode = (HttpStatusCode)status;
return View(statuscode);
}
}
but, when an error occurred, the yellow-page shown, instead of my custom view! can everybody help me please?! Thanks a lot, regards