asp.net mvc keeps overriding text/html content-type with .wml

你。 提交于 2019-11-30 16:28:00

Turns out I hadn't implemented the ActionFilter correctly.. I needed to override the OnResultExecuted method in addition to the OnActionExecuted method. The full attribute looks like this (just add [HtmlOverrideFilter] to your Controllers where needed). Hope this helps someone.

internal class HtmlOverrideFilter : ActionFilterAttribute
{
    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        filterContext.HttpContext.Response.ContentType = "text/html";
    } 

    public override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        filterContext.HttpContext.Response.ContentType = "text/html";
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!