1. 程式人生 > >.net core 2.0 虛擬目錄下載 Android Apk 等檔案

.net core 2.0 虛擬目錄下載 Android Apk 等檔案

當Android 檔案 Apk 放在Asp.net core wwwroot 虛擬目錄下面、訪問是 404,設定Content-Type型別

app.UseStaticFiles();

            //設定實際目錄與虛擬目錄  
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"
wwwroot/Files")), RequestPath = new PathString("/jfiles"), //設定Android APK 下載 ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary<string, string> { { ".apk","application/vnd.android.package-archive
"}, { ".nupkg","application/zip"} }) });