Web api download file example

Web api download file example

web api download file example

ASP.NET Web API - Download File. GitHub Gist: instantly share code, notes, and snippets. Basic C# coding knowledge; Minimum knowledge of Web API For example, when we send the file type as PDF, service will return PDF file if we I ran the project and tried to download all the books in all formats with the. FileStreamResult. Example: Return Image .png) file. Here we will be returning an image from the Controller method. Using.

Web api download file example - rather good

Web api download file example - not

Download file using Web API[Answered] RSS

Hi romah,

romah

Above code works fine in my development machine (downloads all files in all browsers) but I am getting following error while deploying in server. 

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>

<Message>An error has occurred.</Message>

</Error>

Please help.

According to your description, we couldn't directly find the reason why you faced this error.

Could you please post more details error message?

I found you have enable the custom error in your web config, so we couldn't get details error message.

I suggest you could modify the web.config file on the server as below:

<system.web> <customErrors mode="Off" /> <compilation debug="true" targetFramework="4.6.1" /> <httpRuntime targetFramework="4.6.1" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> </system.web>

You could use browser F12 develop tool's network tag to see the details response from the web api.

Besides, if you don't use browser, I suggest you could use postman to send the request and see the details error message.

Best Regards,

Brando

Источник: https://forums.asp.net/t/2143920.aspx?Download+file+using+Web+API
web api download file example

Web api download file example

3 thoughts to “Web api download file example”

Leave a Reply

Your email address will not be published. Required fields are marked *