码迷,mamicode.com
首页 > 移动开发 > 详细

.net core 2.0 虚拟目录下载 Android Apk 等文件

时间:2018-12-10 11:30:07      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:options   pack   ring   虚拟   tty   .net   stat   use   ati   

当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"}
                })
            });

 

.net core 2.0 虚拟目录下载 Android Apk 等文件

标签:options   pack   ring   虚拟   tty   .net   stat   use   ati   

原文地址:https://www.cnblogs.com/w2011/p/10094760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!