In my c# code, I am trying to get filename from content disposition as the content type is application/octet-stream.
But for some urls, the content disposition filename contains spaces or non ascii characters. It causes following exception while creating new content dispostion object.
System.FormatException: An invalid character was found in the mail header: 'R'. at System.Net.Mime.ContentDisposition.ParseValue()
System.FormatException: The specified content disposition is invalid. at System.Net.Mime.ContentDisposition.ParseValue() at System.Net.Mime.ContentDisposition..ctor(String disposition) at Rextester.Program.Main(String[] args)
System.FormatException: An invalid character was found in the mail header: 'Ã'. at System.Net.Mime.MailBnfHelper.ReadQuotedString(String data, Int32& offset, StringBuilder builder, Boolean doesntRequireQuotes, Boolean permitUnicodeInDisplayName) at System.Net.Mime.ContentDisposition.ParseValue()
System.FormatException: The specified content disposition is invalid. at System.Net.Mime.ContentDisposition.ParseValue() at System.Net.Mime.ContentDisposition..ctor(String disposition) at Rextester.Program.Main(String[] args)
Are these errors expected? I read somewhere that it only expects ascii characters. But I am facing issues even in case filename has spaces.
What can be alternative to this? I need to know the extension solely by utilizing the response header.