BlazorInputFile icon indicating copy to clipboard operation
BlazorInputFile copied to clipboard

Could not find 'BlazorInputFile' in 'window'

Open jjohnson3922 opened this issue 4 years ago • 1 comments

For some reason, my server side blazor app no longer works with the BlazorInputFile package. When i attempt to upload a file using this, my chrome dev console is throwing an error.

[2020-03-18T20:31:14.001Z] Error: Microsoft.JSInterop.JSException: Could not find 'BlazorInputFile' in 'window'. Error: Could not find 'BlazorInputFile' in 'window'. at https://localhost/_framework/blazor.server.js:8:30748 at Array.forEach () at p (https://localhost/_framework/blazor.server.js:8:30709) at https://localhost/_framework/blazor.server.js:8:31416 at new Promise () at e.beginInvokeJSFromDotNet (https://localhost/_framework/blazor.server.js:8:31390) at https://localhost/_framework/blazor.server.js:1:19202 at Array.forEach () at e.invokeClientMethod (https://localhost/_framework/blazor.server.js:1:19173) at e.processIncomingData (https://localhost/_framework/blazor.server.js:1:17165) at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args) at BlazorInputFile.InputFile.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

I have tried uninstalling and reinstalling the package, clearing nuget cache, rebuilding the project, all with no luck. I am not sure where to look..

jjohnson3922 avatar Mar 18 '20 20:03 jjohnson3922

Does the browser dev tools show an error that the inputfile.js couldn't be loaded? If so you probably need to add app.UseStaticFiles(); (with no arguments) in your Configure(IApplicationBuilder app) method in your Startup class. This is because UseStaticFiles also hosts static files from packages.

nloum avatar Jul 10 '20 13:07 nloum