Search code examples
jwasm

Can I serve a wasm file in ASP.NET?


I am using a third party javascript file in a project that makes a call to a wasm file. Can I call this and server it the same way I do a javascript file in script tags?


Solution

  • Yes, For Asp.Net Core we did the following to Serve the file:

        // https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2#fileextensioncontenttypeprovider
        var provider = new FileExtensionContentTypeProvider {Mappings = {[".wasm"] = "application/wasm"}};
    
        app.UseStaticFiles(new StaticFileOptions
        {
            ContentTypeProvider = provider,
            ...
        }