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

前端 未结 1 567
一向
一向 2021-01-03 13:04

I\'m developing an website which is to be viewed on mobile (cellphone) devices. I\'m just using plain HTML 4.01, nothing special at all. The pages render fine on all the mob

相关标签:
1条回答
  • 2021-01-03 13:31

    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";
        }
    }
    
    0 讨论(0)
提交回复
热议问题