Asp.net 控制器。以无内容类型的文本文件执行渲染

Asp.net 控制器。以无内容类型的文本文件执行渲染,asp.net,asp.net-mvc,contenttype,Asp.net,Asp.net Mvc,Contenttype,当404或500发生时,页面显示为文本文件。响应中的内容类型为空。如何修复此问题,使内容呈现为“text/html”页面 我添加了这个,它修复了它 if (!context.Request.IsAjaxRequest()) { context.Response.ContentType = "text/html"; if (!context.Request.IsAjaxRequest()) { context.Res

当404或500发生时,页面显示为文本文件。响应中的内容类型为空。如何修复此问题,使内容呈现为“text/html”页面


我添加了这个,它修复了它

if (!context.Request.IsAjaxRequest())
        {
            context.Response.ContentType = "text/html";
if (!context.Request.IsAjaxRequest())
        {
            context.Response.ContentType = "text/html";