Filestreamresult is resulting in 500 internal server error on Pivotal Cloud Foundry (PCF). When I run angular app on localhost and .netcore webapi on localhost I am able to download the file but on cloudfoundry it does not work.
I have researched and found some solutions but none worked in my case. I have tried following links https://www.syncfusion.com/forums/125221/asp-net-core-sending-a-generated-pdf-directly-to-browser https://weblogs.thinktecture.com/pawel/2017/03/aspnet-core-webapi-performance.html
- I have tried returning
File(mstrm,"text/plain")
works on localhost but not on PCF. - I have also tried
File(mStrm, "application/octet-stream")
works on localhost but not on PCF. - My other API endpoints work on PCF, just this one is causing the error.
- Also checked logs on PCF but it only shows that it resulted in 500 error.
This api is using dotnet_core_buildpack and is hosted on cflinux.
public FileStreamResult appConfigure([FromBody] Test test) {
var testFile = _test.generateScript(test); MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(testFile)); mStrm.Position = 0; return new FileStreamResult(mStrm, "text/plain") { FileDownloadName = test.testName + ".txt" }; }
result should be test.txt file returned with http 200 response. But I am receiving 500 error POST https://testapp.apps.pcf.testapp.com/api/test/genscript 500 (Internal Server Error)
Have been stuck on this for last 2 days, any help is much appreciated :)