I am developing a local server using a self-service ServiceStack. I hard-coded the demo web page and allowed its access to localhost:8080/page :
public class PageService : IService<Page> { public object Execute(Page request) { var html = System.IO.File.ReadAllText(@"demo_chat2.html"); return html; } }
It works great for Chrome / Firefox / Opera, however IE will handle the URL as a download request and promote "Do you want to open or save the page from a local host?"
What should I do to make IE treat the URL as a web page? (I already added the doctype headers to the demo page, but that can't stop IE from seeing this as a download request.)
EDIT.
Ok I used Fiddler to check the response when accessing localhost. The responses that IE and Firefox receive are exactly the same. And in the header, the content type is written as:
Content-Type: text/html,text/html
Firefox treats this type of content as text/html , however IE does not recognize this type of content (it only recognizes one text/html )!
So, it makes me believe that this is due to an error in SS.
Decision
One solution is to explicitly set the content type:
return new HttpResult( new MemoryStream(Encoding.UTF8.GetBytes(html)), "text/html");
source share