-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting binary support working in blueprint ASP.NET Core Web App #240
Comments
Hey bro, I followed your steps but still could not get the image/icon. Did you do anything more than what you said? Thanks! |
Yeah, actually you need to set BinaryMediaTypes to BinaryMediaType
|
ignore it :) |
I'm just going to leave this here so it hopefully saves someone else an hour... The default "Accept" header in the request for .png files is "image/apng" not "image/png"! Everything worked once I added: protected override void Init(IWebHostBuilder builder)
{
//NB: Serverless WebAPI needs to have special config to serve binary file types:
RegisterResponseContentEncodingForContentType("image/png", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/jpeg", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/gif", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/apng", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/webp", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/x-icon", ResponseContentEncoding.Base64);
builder
.UseStartup<Startup>();
} Edit: Accept headers for Chrome and IE11 seem to use |
I am having some problems getting binary support working with the ASP.NET Core 2 integration.
So I tried with the "ASP.NET Core Web App" blueprint, and it actually contains a
favicon.ico
file, which is not displayed when published.I think the blueprint should work out of the box in the same way as running on your own machine. Or maybe you should just remove the favicon.ico.
I read the instructions with regards to Binary Response Content here: https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.AspNetCoreServer/README.md
So I added the following line to
LambdaEntryPoint.Init()
:RegisterResponseContentEncodingForContentType("image/x-icon", ResponseContentEncoding.Base64);
And I added the Binary Media Type in console:
Lambda log correctly shows that response is base64 encoded:
API Gateway log:
What part am I missing?
I found quite many posts with people not making binary work with the lambda proxy integration. So I suspect there is a general issue.
The text was updated successfully, but these errors were encountered: