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);

    ...
  • 相关阅读:
    缺少一个=出现的问题
    快速排序+归并排序
    ACwing简单题(14)
    浅谈#ifndef
    fstream 使用详解
    _stat函数的使用
    关于文件结构体的使用
    new的使用
    ACwing13题目
    ACwing13题
  • 原文地址:https://www.cnblogs.com/xixifusigao/p/3953279.html
Copyright © 2011-2022 走看看