Mike van der Meulen's Blog about day-to-day, work-related "stuff", often technical, rarely exciting, just the everyday things that go on.
Normally, dealing with Internet Explorer is painful for anyone having to design or skin a site and, like everyone else, I usually don't enjoy dealing with browser incompatibilities. I thought I was well shielded from IE as I was just writing some code today, working on some browser independent stuff. Or so I thought.
I had to display a text file, which happened to contain HTML. Simple enough: set the ContentType to text/plain and display the content. Not so fast! Internet Explorer 8 kept displaying it as a web page. I tried reasoning with it but it just ignored me. Then I showed Internet Explorer that Chrome could do it correctly. Chrome dutifully obliged and displayed my text data. IE was not impressed, even when I brought reinforcements, Safari and Mozilla.
So there I was, feeling abandoned and bullied at the same time. Google to the rescue! Sure enough, I found an old bug report on Microsoft's site (http://support.microsoft.com/kb/329661) linking to another entry documenting a Registry hack and a fix that supposedly is available upon request. This KB article has this disclaimer "This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated." Funny thing is, IE8 is supported, so Microsoft must have decided in their wisdom, that this is the way things must be. Or maybe they're busy fixing real problems, like CSS support, HTML5 or whatever.
It's not difficult to work around the problem (just like all your CSS hacks!). For IE, change the headers by adding Content-Disposition so the data is opened/saved rather than displayed as direct content, as in:
public ActionResult DisplayHtmlSource(long reportItemID) {
ReportItem reportItem = ReportItem.VerifyReportItemID(reportItemID);
HttpBrowserCapabilities caps = System.Web.HttpContext.Current.Request.Browser;
if (caps.Browser == "IE") {
HttpResponseBase response = ControllerContext.HttpContext.Response;
response.AppendHeader("Content-Disposition", "attachment;filename=\"Text.txt\"");
}
return Content(reportItem.PageInfo.RawHtml, "text/plain");
} It's not earth-shattering, but really, I did not need this "distraction" on my to-do list. You do wonder who comes up with these "design ideas" that seem of little value and who decides not to fix them.
Loading