Why does Http header contains "X-SourceFiles"?

Question:

Using a FileStreamResult in ASP.NET MVC 3, I get a response header like

X-SourceFiles =?UTF-8?B?RDpcUHJvamVjdFxqYWNvYlx0ZXN0?=

 

Answer:
The header is understood by certain debugging modules in IIS / IIS Express. It contains the base64-encoded path to the source file on disk and is used to link a page's generated output back to that source file. It's only generated for localhost requests, so you don't need to worry about it being displayed to the world when you deploy the application to an actual server.

 

Updated:

It is not the root cause. I re-checked this issue. only IE has this problem, Chrome is ok. It is caused by the Chinese file name. if the file name doesn't have double byte char, all are ok.  The workaround is to escape the file name when client browser is IE

... 
   string bName = HttpContext.Current.Request.Browser.Browser;
            if (bName  == "InternetExplorer")
            {
                fileName = Uri.EscapeDataString(fileName);
            }    

  result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
  result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

  result.Content.Headers.ContentDisposition.FileName = fileName;
  result.Content.Headers.Add("x-filename", fileName);

...

 

转载于:https://www.cnblogs.com/xixifusigao/p/3953279.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值