gpt4 book ai didi

C# HttpListener : IE11 does not apply CSS

转载 作者:行者123 更新时间:2023-11-28 07:21:00 24 4
gpt4 key购买 nike

我编写了一个简单的 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;

最佳答案

正如 Eser 所说,

response.ContentType = mime;

是要走的路。

关于C# HttpListener : IE11 does not apply CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32087947/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com