LoginSignup
2
1

More than 5 years have passed since last update.

.NET Core で静的ファイルが見つからなかったときの対処法

Last updated at Posted at 2017-08-24

Live2D Cubism SDK for JavaScript のアーリーアクセスがはじまりました!
https://live2d.github.io/#js

さっそく、.NET Core で作成していたWebアプリに組み込んでみました。

モデルファイルが Not Found!?

なぜか、データが Not Found となり、モデルが表示される気配がありません。
テクスチャファイルは読めているのに・・・

原因は、MIME でした。

Live2D Cubismモデルは".moc3"、モーションは".motion3.json"です(Cubism 2.x系は".moc" ".mtn")
要は、このファイルの拡張子が不明のため、読めなかったようです。

StartUp.cs に下記の記述を記載すれば、全ての拡張子が読めるようになります。

StartUp.cs
public void Configure(IApplicationBuilder app)
{
    app.UseStaticFiles(new StaticFileOptions()
    {
        ServeUnknownFileTypes = true
    });
}

本当はセキュリティ的な意味でも、特定の拡張子だけを反映するようにしたほうがいいかなーとは思います。

余談:IISでいうと...

これですね。
2017-08-24_15h40_30.png

参考

Introduction to working with static files in ASP.NET Core

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1