[英]C# HttpListener: IE11 does not apply CSS
我編寫了一個簡單的HttpListener應用程序,它為離線html應用程序提供服務。 在Firefox中,一切工作正常,但IE並未應用css文件中的樣式。 它要求他們,我將它們發回,但不適用它們...
// Construct a response.
List<byte> bytes = new List<byte>();
using (FileStream fs = new FileStream(path, FileMode.Open))
using (BinaryReader br = new BinaryReader(fs))
while (br.BaseStream.Position != br.BaseStream.Length)
bytes.Add(br.ReadByte());
buffer = bytes.ToArray();
// Get a response stream and write the response to it.
response.ContentLength64 = buffer.Length;
response.RedirectLocation = path;
switch (ext)
{
case "css":
mime = "text/css";
break;
case "js":
mime = "text/javascript";
break;
case "png":
mime = "image/png";
break;
case "jpg":
mime = "text/jpeg";
break;
case "gif":
mime = "image/gif";
break;
}
response.AddHeader("content", mime);
using (Stream output = response.OutputStream)
output.Write(buffer, 0, buffer.Length);
break;
就像埃瑟說的
response.ContentType = mime;
是要走的路。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.