.Net Core 3.1 API with React front end suddenly shutting down in Visual Studio IIS Express - using file-saver

Heather Witt 1 Reputation point
2021-07-22T16:43:43.047+00:00

I have an odd issue related to running a React front end with a .Net Core 3.1 Web API. I used the Visual Studio template to create the app, so the client app exists inside my .Net Core project and is launched when I launch the API.

I have an API endpoint that returns a text/csv file via a FileStreamResult, and then I am using the npm package file-saver (https://www.npmjs.com/package/file-saver) to allow the client to save the file on the front end. The file is being returned and saved successfully, but every time I run the saveAs function from my client app, the API shuts down when running in IIS on Visual Studio It just stops. Nothing in the logs, though I have set them to verbose. It shows the API being hit and the response being returned, but nothing else. I've also searched the Event Logs, but can't find any errors at the times of the shutdowns. It happens consistently. If I dont' save the file, the API does not shut down, but as soon as I save the file, it does.

If I run the API from Powershell using 'dotnet run,' the file is returned and saved successfully and the API does not shut down. I feel like this might be an IIS configuration issue, but I'm not sure how to resolve it.

I'm running Visual Studio Community 2019 version 16.10.2 and .Net Framework version 4.8.04084

The code in my Startup.cs that runs the React app is
`app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";

if (env.IsDevelopment())
{
    spa.UseProxyToSpaDevelopmentServer("http://localhost:3000");
}

});`

Thanks in advance....

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,188 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
945 questions
{count} votes

2 answers

Sort by: Most helpful
  1. PengGe-MSFT 3,336 Reputation points
    2021-07-23T05:57:12.857+00:00

    Hi @Heather Witt

    Welcome to Microsoft Q&A!

    Are you running the program in Debug mode?

    You can try to run the program in Release or Kestrel mode to detect whether the issue exists. If the issue only occurs in Debug mode, can you try to collect logs in Visual Studio? If not, can you share more information to help us reproduce the issue?

    I noticed that you have used this JS package, please make sure that the size of the file you want to save does not exceed the limit of this package, and whether the RAM is sufficient when saving.

    Sincerely,
    Peng
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Heather Witt 1 Reputation point
    2021-07-27T20:45:00.167+00:00

    Thank you @PengGe-MSFT !

    It happens in both Debug and Release mode from Visual Studio, but not when running from Powershell using dotnet run.

    The files I'm working with are small .csv files - the largest so far was 118KB, so I don't think file size or RAM is an issue.

    The output window shows the following:

       The thread 0x2dbc has exited with code 0 (0x0).  
       The program '[10308] iisexpress.exe' has exited with code -1 (0xffffffff).  
    

    Once I turned on logging for VS, the following appeared in the Event Viewer:

       Fault bucket , type 0  
       Event Name: VisualStudioNonFatalErrors2  
       Response: Not available  
       Cab Id: 0  
       Problem signature:  
       P1: iisexpresstray.exe  
       P2: 7.1.4403.1855  
       P3: vs.telemetry.internalfault  
       P4: System.IO.FileLoadException  
       P5: Microsoft.VisualStudio.Telemetry  
       P6: Microsoft.VisualStudio.ApplicationInsights.Channel.UniversalTelemetryChannel.IsAvailable  
       P7: _  
       P8: _  
       P9: _  
       P10: _  
       Attached files:  
       \\?\C:\Users\...\AppData\Local\Temp\VSFaultInfo\210727_033356_9009600\ErrorInformation.txt  
       These files may be available here:  
       Analysis symbol:  
       Rechecking for solution: 0  
       Report Id: 0de80fc2-af82-4385-b6e1-864e41d2f7d3  
       Report Status: 268697600  
       Hashed bucket:  
       Cab Guid: 0  
    

    And the file it references looks like:

       Error Information  
       AppInsightsEvent Name = vs/telemetry/internalfault  
                 Description = Exception in SessionChannel.EventProcessorChannel ProcessEvents Channel = eventProcessorChannel  
            TelemetrySession = '72b0c255-e669-4f2f-853d-faf98179cae7' Started = True OptIn=True IsInitialized = True Cloned = False  
             WatsonEventType = VisualStudioNonFatalErrors2  
                    UTC time = 2021-07-27T20:33:56  
        Exception:  
        System.IO.FileLoadException  
        Could not load file or assembly 'Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)  
        Microsoft.VisualStudio.ApplicationInsights.Channel.UniversalTelemetryChannel.IsAvailable()  
        Microsoft.VisualStudio.Telemetry.SessionChannel.AsimovAppInsightsClientWrapper.CreateAppInsightsChannel(TelemetryConfiguration config)  
        Microsoft.VisualStudio.Telemetry.SessionChannel.BaseAppInsightsClientWrapper.Initialize(String sessionId, String userId)  
        Microsoft.VisualStudio.Telemetry.EventProcessorRouter.RouteEvent(TelemetryEvent telemetryEvent, String sessionId, Boolean isDropped)  
        Microsoft.VisualStudio.Telemetry.SessionChannel.EventProcessorChannel.ProcessEvents()  
       WerReportAddDump PID=33664 iisexpresstray WerDumpTypeMiniDump  
    

    Thanks again for your reply.