我需要的只是純文本的錯誤信息。但是ASP.NET正在從每個錯誤中做出一些HTML報告輸出。如何擺脫ASP.NET MVC中的HTML錯誤報告?
我有一個jquery ajax調用,並且當拋出一個錯誤時,我將所有的垃圾傳遞給客戶端。
我創建了一個過濾器屬性,但沒有幫助。
public class ClientErrorHandler : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
var responce = filterContext.RequestContext.HttpContext.Response;
responce.Write(filterContext.Exception.Message);
responce.ContentType = MediaTypeNames.Text.Plain;
filterContext.ExceptionHandled = true;
}
}
編輯
我看到this
,我倒要看看究竟什麼是這裏filterContext.Exception.Message
請包括您在客戶端看到的內容以及您希望看到的內容。 – 2010-08-26 12:23:11
好的,我編輯了我的帖子。 – user137348 2010-08-26 12:29:23
您的web.config文件中的CustomErrors =「Off」?嘗試在你的web.config中打開CustomErrors =「On」或CustomErrors =「RemoteOnly」來抑制死亡的.NET黃色屏幕(這是你看到的HTML代碼)。 – Tommy 2010-08-26 14:45:59