.net core 2.0 虛擬目錄下載 Android Apk 等文件

當Android 文件 Apk 放在Asp.net core wwwroot 虛擬目錄下面、訪問是 404,設置Content-Type類型android

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"}
                })
            });
相關文章
相關標籤/搜索