다음 기본 컨트롤러를 만들어 InvalidOperationException (보기를 찾을 수 없음)에 사용자 지정 404를 표시했습니다. 어떤 이유로, 나는 페이지를 열 때 404을 발생하게 들어 IIS 7.5 Windows 2008 R2 로컬로 500 개의 원격 및 사용자 지정 404 제공
public class HandlesViewNotFoundController : Controller
{
protected override void OnException(ExceptionContext filterContext)
{
//InvalidOperationException is thrown if the path to the view
// cannot be resolved by the viewengine
if (filterContext.Exception is InvalidOperationException)
{
if (!filterContext.ExceptionHandled)
{
filterContext.ExceptionHandled = true;
filterContext.Result = new ViewResult { ViewName = "_404" };
filterContext.HttpContext.Response.StatusCode = 404;
Response.Clear();
// Clear the error on server.
Server.ClearError();
// Avoid IIS7 getting in the middle
Response.TrySkipIisCustomErrors = true;
}
}
base.OnException(filterContext);
}
}
, 그것은 로컬 때 디버깅 완벽하게 작동하고, 로컬 서버에서 페이지를 볼 때,하지만 난에 확인 동일한 URL을 볼 경우 서버를 원격으로 실행하면 내부 서버 오류 (500)가 반환됩니다.
아이디어가 있으십니까?
나는 그것을보기 _404 공유 폴더에 있고 전체보기 및 속성 "콘텐츠"로 표시됩니다 (부분 뷰는 일반적으로 밑줄로 시작하기 때문에 나는이 질문이)입니다 걸릴? – viperguynaz
실제로 공유되어 있으며 콘텐츠로 표시되어 있습니다. _Layout.cshtml에서 상속받은 페이지입니다. 공유 자원 이름 지정에 따라 _ – NKCSS