Response.WriteFile() 奇怪的字符问题
您好,在我使用 MVC 3 的 aspx 页面中,我有以下代码:
<%Response.WriteFile("/Content/Bing.htm"); %>
这是一个包含 BING 搜索框代码的包含文件。
在包含 DIV 的顶部,出现了一个奇怪的字符:

我意识到它可能是一个 BOM 字节顺序标记,但我一生都无法弄清楚为什么它会出现以及如何摆脱它。 bing 代码的其余部分显示并且工作正常。
基本上我希望能够在我的 aspx 页面中包含 htm 文件。
任何帮助将不胜感激。谢谢。
Hello in my aspx page using MVC 3, I have the following code:
<%Response.WriteFile("/Content/Bing.htm"); %>
Which is an include file that contains BING search box code.
At the top of the containing DIV, a strange character is appearing:

I realize it it probably a BOM Byte Order Marker, but for the life of me I cannot figure out why it is showing up and how to get rid of it. The rest of the bing code shows up and works fine.
Basically I want to be able to include htm files in my aspx pages.
any help would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是在文件里吧在二进制文件编辑器中编辑该文件,您应该能够查看并删除它。或者,使用
File.ReadAllText
之类的内容读入文件,然后将字符串写出到响应中。我希望能够去除 BOM - 并具有在响应中使用一致编码的额外好处,即使您有不同编码的文件。 (当然,您在读取它们时需要指定编码。)Presumably it's in the file. Edit the file in a binary file editor, and you should be able to see and remove it. Alternatively, read in the file in with something like
File.ReadAllText
and then write out the string to the response. I'd expect that to strip the BOM - and have the additional benefit of using a consistent encoding in the response, even if you have files of different encodings. (You'd need to specify the encoding when reading them, of course.)