Closed vidya091209 closed 2 years ago
Please share the full code of the controller method.
[MiddlewareFilter(typeof(JsReportPipeline))]
public async Task
var filename=$"attachment; filename=\"Customer List_{DateTime.Now.ToString("MM-dd-yy-HH-MM-ss") }.pdf\"";
HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf)
.OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] =filename);
return View("Customer", await _customerService.GetCustomerSearchAsync(new ViewModel.CustomerFilter() { CustomerTypeId=id }));
}
Hm, this looks good. I don't see any reason why it should return something different in azure web app. Do you get this problem just in this particular case or is it general?
is there any limitation in using azure web app. i have seen there was a issue reported for the same.
See it in the docs https://jsreport.net/learn/dotnet-local#azure-web-apps
this means at minimum i have to have linux container running
Yes. However the chrome should just fail on windows. It is strange that it is returning html for you.
Hi I have modified my docker file as
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN apt-get update && \
apt-get install -y gnupg libgconf-2-4 wget && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install -y google-chrome-unstable --no-install-recommends
ENV chrome:launchOptions:args --no-sandbox
The main issue i am facing is adding nuget package
nuget package Include="jsreport.Binary.Linux"
I prepared an example for docker and azure web app. Can you check it? How it works for you?
thanks. it is working. but performance wise it is too slow. for 57KB report it is taking more than 1 minute.
The rendering should be slow just the first time. Isn't it?
You can try to use this "AsWebServer" switch https://jsreport.net/learn/dotnet-local#utility-or-web-server which can speed it up a bit.
What azure plan do you use? How is the performance on your local?
Its Standard S1. locally it is a faster.
but you recommend to use "It is generally recommended to use the utility based strategy in production"
Hi @pofider one the same instance i also wanted to support to download excel. this my local running code but in docker it is showing as inline
HttpContext.JsReportFeature() // the normal jsreport base url injection into the html doesn't work properly with docker and asp.net because of port mapping // the project typically starts with some http://localhost:1234 url but inside docker the url is http://localhost .Configure((req) => { req.Options.Base = "http://localhost"; req.Template.HtmlToXlsx = new HtmlToXlsx() { HtmlEngine = "chrome" }; }) .Recipe(Recipe.HtmlToXlsx);
one the same instance i also wanted to support to download excel. this my local running code but in docker it is showing as inline
you mean it shows in excel online? I tried the same code in the previously shared example and excel gets downloaded if I run the controller action in a browser. However, you can change the AfterRender hook to change the content disposition header.
thanks. it is working. but performance wise it is too slow. for 57KB report it is taking more than 1 minute
I tried the previously shared example with demo invoice on S1 plan and it runs 4s. You can also deploy jsreport as standalone web app from docker image "jsreport/jsreport:2.3.0" to get it separated with better architecture and better performance. You would get like 2.5s there on S1. Unfortunatelly S1 is quite slow for running a heavy tool like headless chrome.
No excel report is rendering as html. please update the sample code https://github.com/jsreport/jsreport-dotnet-example-docker to support excel download. thanks.
You can also consider using [jsreportonline(https://jsreport.net/online) instead of the jsreport.Local
. It is in many situations more effective for maintenance and resources cost. Just giving you options...
I added the excel example, but there is nothing interesting. Check it out.
this is how my report is looking right now instead of getting downloaded.
and we don't need this right? .OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] = filename);
and we don't need this right?
No it should not be needed.
It must be something with your setup, I don't know. Try to compare it with my example and find out what is different. Or share a simple sample repo for me so I can take a look.
A lot has changed in the jsreport v3 sdk, please test it there and come back if you have still troubles.
I am hosting a .net core app in azure web app. services.AddJsReport(new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create()); HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf,) .OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] =filename); i want to download the report. locally it works but from web app it just render as html report.