I am new to ASP.NET Core. I have written a code that works on my local computer but when I publish the app to our test environment the behavior is strange. The scenario is as follows:
When the user clicks a link, the app exports data to an excel file which is downloaded. On my PC / dev env, the data is downloaded fine and you can see it on the Excel sheet however on Test, it is rather the webpage that is on the Excel sheet hence giving a message "The file format and extension of summary.xls don't match. The file could be corrupted or unsafe" when you open the Excel file.
I'm doing something similar with product called Gembox. In a nutshell, I create the excel file and save it to a path under the website. In my case it is normally a folder called ExcelTemp. I save the file to that folder then use the following code to save it on the enduser's pc. This code will prompt them to save it unless the browser is set to automatically put it somewhere.
Also, we have checked the logs and there are no error messages to help point us to the root cause of the issue
Well, that's hardly surprising - your code swallows any exceptions that are thrown!
Fokwa Divine wrote:
catch (Exception ex)
// Exception is swallowed; no details will be logged.
At a guess, the server has response buffering turned off for performance reasons. As a result, the Stream returned from Context.Response.Body is not "seekable", and the wb.Write call is failing for that reason.
Looking through the NPOI examples repo[^], you should write the workbook to a MemoryStream first, then copy that to the response.
Also, there's no need to use HttpContextAccessor within your view; you already have access to the current response via the Context.Response property.
I would strongly recommend generating the workbook in your controller, or preferable a service that you call from your controller, and sending it back to the client in a custom response type.
me again, old man again .. I have used Scanner set as com port and I like to change it to use Bluetooth, used as com port.
I have register device and change it to use it as com port in Windows 11. I am using SerialPort and add
. This event never happens. I cannot find any suggestion. Can you help me please ?
no errors, The Receive Data Event not working. the com port is in /foreach(string port in ports) / as well it shows as com port in Device Manager as 'Standard Serial over Bluetooth link (COM4)'. I use standard Serial port structure <serialport(port)>. It works as HID, when I scan barcode while in Note Pad ?!!?? In device manager I have its HID disabled. When I change the driver to do as com port, my software works. I have an issue with the com port driver supplied with the scanner, and this is the reason I like to change it.
maybe I have not been clear. I do not want to use the faulty driver as it has problems. This is why I like to use Scanner via Bluetooth and redirected to operate as com port. The Bluetooth driver is Microsoft and redirection is done via Windows 11, so no faulty driver to be used.
I want to use Bluetooth connection and use it to communicate as serial port with <serialdatareceivedeventhandler> to operate. Maybe I am asking for something which cannot be done
appreciate you help