I have a method to get the filename in server but it doesn't cover all situations.
The link below return the filename as attachment;filename=WinRAR.zip;filename*=UTF-8''WinRAR.zip
. The correct filename is WinRAR.zip. How to cover all situations to get the correct filename?
string fileName = response.Headers["Content-Disposition"] != null ?
response.Headers["Content-Disposition"].Replace("attachment; filename=", "").Replace("\"", "") :
response.Headers["Location"] != null ? Path.GetFileName(response.Headers["Location"]) :
HttpUtility.UrlDecode(System.IO.Path.GetFileName(response.ResponseUri.ToString()));