Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using HttpPostedFileBase to upload a file using ASP.NET MVC. I need to post this to a API call and i am getting a error "StatusCode: 403, Reason Phrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent". This is because i am passing file content as "application/octet-stream", where as API call wants the content type as "application/vnd.qlik.sense.app". Many posts in internet says that HttpPostedFileBase is a read only and we cannot change the content type. Can anybody let me know how we can change the content type of HttpPostedFileBase. Is this possible??

What I have tried:

I am using HttpPostedFileBase to upload a file using ASP.NET MVC. I need to post this to a API call and i am getting a error "StatusCode: 403, Reason Phrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent". This is because i am passing file content as "application/octet-stream", where as API call wants the content type as "application/vnd.qlik.sense.app". Many posts in internet says that HttpPostedFileBase is a read only and we cannot change the content type.
Posted
Updated 21-Mar-18 3:26am
Comments
#realJSOP 21-Mar-18 9:21am    
The "What I Tried" section should show the code you tried (if you tried anything at all). It's NOT supposed to be a repeat of your question.

1 solution

Have you tried adding application/vnd.qlik.sense.app as a mime type in your web.config file? Something like this:

XML
<System.webServer>
    <staticContent>
        <remove fileExtension=".sense.app" />
        <mimeMap fileExtension=".sense.app" mimeType="qlik_sense_app" />
    </staticContent>
</system.webServer>


You may have to remove ".sense" from the fileExtension attribute, because I don't now right off hand if that format is usable by IIS.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900