0
I need to set up a generic error page for my site, added the following code in the web config:
<system.web>
<trust level="Full" />
<customErrors mode="On" defaultRedirect="~/Views/Error/index.cshtml">
<error redirect="~/Views/Error/index.cshtml" statusCode="500" />
</customErrors>
</system.web>
I created the Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SiteTeste.Controllers
{
public class ErrorController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
I created the View:
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container-fluid">
<div style="margin-top:100px;margin-bottom:100px;" class="col-md-offset-3 col-md-6">
<h1>Ocorreu um erro durante a requisição.</h1>
Ocorreu um erro interno, por gentileza repita o processo ou @Html.ActionLink("Entre em contato","ContactUs","Home") caso o erro persista.
</div>
</div>
But when an error happens what appears to me is the message:
Error.
An error occurred while Processing your request.
Now I understood where this page came from, but did not solve the problem, how to change this page. :/
– Leonardo Bonetti
You edited the
~\Views\Shared\Error.cshml
or failed to redirect to your?– Leandro Angelo
I created a View Error
– Leonardo Bonetti