问题描述
我在 net 5 上有一个 mvc 项目,我必须能够使用 .wasm 文件。
我在 Startup.cs 的配置中做了以下操作
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = context =>
{
IHeaderDictionary headers = context.Context.Response.Headers;
string contentType = headers["Content-Type"];
if (contentType == "application/x-gzip")
{
if (context.File.Name.EndsWith("js.gz"))
{
contentType = "application/javascript";
}
else if (context.File.Name.EndsWith("css.gz"))
{
contentType = "text/css";
}
headers.Add("content-encoding","gzip");
headers["Content-Type"] = contentType;
}
},ContentTypeProvider = new FileExtensionContentTypeProvider() {
Mappings = {[".wasm"] = "application/wasm" },},DefaultContentType = "application/octet-stream"
});
wasm 流编译失败:类型错误:无法在“WebAssembly”上执行“编译”:响应 MIME 类型不正确。应为“应用程序/wasm”。
如何才能读取此类文件?
这种类型的文件只发生在我身上,其余的工作正常
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)