zoukankan      html  css  js  c++  java
  • 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);

    ...
  • 相关阅读:
    Sky中国War3的旗帜
    2008流行趋势发布暨07届学生毕业秀(上海大学主办)
    随便写一下
    六一节——小朋友们快乐
    HEI
    Update my blog to improve my idea.
    由ipod引起的奇遇记
    加勒比海盗
    “老板娘”请客吃饭
    蚂蚁工坊
  • 原文地址:https://www.cnblogs.com/xixifusigao/p/3953279.html
Copyright © 2011-2022 走看看