iis 7 - asp.net mvc keeps overriding text/html content-type with .wml -
I am developing a website that is being viewed on mobile (cellphone) devices. I'm just using plain HTML 4.01, not very special. Except Nokia Series 40 1-5 versions, we have presented pages properly on all mobile browsers. On closer inspection, it seems that the IIS is automatically rendering html with the content-type of text / vnd.wap.wml
instead of text / html
. Since we are not using WAP, the page fails with error.
I am using ASP.Net MVC 1.0, so I've added a ActionFilterAttribute
to override content-type. This code runs but the client still comes out as vnd.wap.wml.
I am using this principle;
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt ;! DOCTYPE HTML PUBLIC "- // W3C / / DTD HTML 4.01 Transitional // N" "http://www.w3.org/TR/html4/loose.dtd" & gt;
It is worth noting that vnd.wap.wml first is worth Accept-Encoding
specified by mobile browser, so I IIS7, so this offer Let's take it. And I think MVC does not specifically mention .html (or .aspx) files, maybe the mime-type is being skipped? I suppose it's probably an IIS fine rather than a code properly.
Any help is greatly appreciated!
Turns out I ActionFilter was not implemented correctly .. I OnResultExecuted than OnActionExecuted method Need to override the method. The full feature looks like this (add the [HtmlOverrideFilter] to your controllers where necessary. Hopefully this does help someone
inner 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"; }}
Comments
Post a Comment