[![introducir la descripción de la imagen aquí][1]][1]
Saben porque pasa esto o otra forma de hacerlo?
Solucion:
Genere un ErrorController
public class ErrorController : BaseController
{
public ActionResult NotFoundLogin()
{
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
return RedirectToAction("Login", "Home");
}
public ActionResult NotFoundIndex()
{
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
return RedirectToAction("Index", "Home");
}
}
Preferi cambiar a usar Application_Error y hacer la redireccion de la siguiente manera:
protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
// Process 404 HTTP errors
var httpException = exception as HttpException;
if (httpException != null && httpException.GetHttpCode() == 404 && !IsWebApiRequest())
{
Response.Clear();
Server.ClearError();
Response.TrySkipIisCustomErrors = true;
// Call target Controller and pass the routeData.
IController controller = new ErrorController();
var routeData = new RouteData();
if (Request.IsAuthenticated)
{
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "NotFoundIndex");
}
else
{
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "NotFoundLogin");
}
var requestContext = new RequestContext(
new HttpContextWrapper(Context), routeData);
controller.Execute(requestContext);
}
}
Saludos. [1]: https://i.sstatic.net/Uf9Be.png