我写了一个简单的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;
答案 0 :(得分:0)
像Eser说的那样,
response.ContentType = mime;
是要走的路。