How to encode the filename parameter of Content-Disposition header in HTTP?

前端 未结 18 1783
北荒
北荒 2020-11-21 06:15

Web applications that want to force a resource to be downloaded rather than directly rendered in a Web browser issue a Content-Disposition hea

18条回答
  •  别跟我提以往
    2020-11-21 06:57

    in asp.net mvc2 i use something like this:

    return File(
        tempFile
        , "application/octet-stream"
        , HttpUtility.UrlPathEncode(fileName)
        );
    

    I guess if you don't use mvc(2) you could just encode the filename using

    HttpUtility.UrlPathEncode(fileName)
    

提交回复
热议问题