Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# webapi return file

[HttpGet]
public HttpResponseMessage Generate()
{
    var stream = new MemoryStream();
    // processing the stream.

    var result = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new ByteArrayContent(stream.ToArray())
    };
    result.Content.Headers.ContentDisposition =
        new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
    {
        FileName = "CertificationCard.pdf"
    };
    result.Content.Headers.ContentType =
        new MediaTypeHeaderValue("application/octet-stream");

    return result;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: csharp Console.Read(); 
Csharp :: how to cut a string in c# 
Csharp :: how to change color of part from the text in textblock wpf 
Csharp :: serenity frameword order column 
Csharp :: c# standard microphone decibels 
Csharp :: C# Linq item index 
Csharp :: asp net saber ip address of client machine IIS 
Csharp :: how to check type in c# 
Csharp :: unity dropdown 
Csharp :: c# window form align right bottom 
Csharp :: monogame print 
Csharp :: c# group array based on first character 
Csharp :: translate int to string with x 0 before c# 
Csharp :: eventsource web api c# 
Csharp :: how to exit winforms application and shutdown pc in c# 
Csharp :: c# selenium xunit testing 
Csharp :: how to fade c# form 
Csharp :: web client ignore ssl error 
Csharp :: Ignore case string linq c# 
Csharp :: #grid 
Csharp :: c# how to get a file path from user 
Csharp :: w3develops 
Csharp :: unity error log 
Csharp :: How to get selected item from Dropdown in GridView 
Csharp :: c# slice array 
Csharp :: unity how to check index of enum 
Csharp :: winforms combobox get selected text 
Csharp :: c# list to observablecollection 
Csharp :: csv to xml using xmldocument c# 
Csharp :: truncate c# 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =