在NET CORE MVC專案下加入Vue MIMEType
2021, May 02
以往在 .NET Framework 中引用Vue時,需添加MIMEType在AppSetting 在.NET CORE 中,只需要加入以下幾行在Startup.cs中
.NET CORE 一般專案
// 添加mimeType
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".vue"] = "application/javascript";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
.NET Minimal API
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".vue"] = "application/javascript";
app.UseFileServer(new FileServerOptions {
RequestPath = "",
FileProvider = new Microsoft.Extensions.FileProviders
.ManifestEmbeddedFileProvider(typeof(Program).Assembly, "wwwroot"),
StaticFileOptions = {
ContentTypeProvider = provider
}
});