• <small id='8X2zf'></small><noframes id='8X2zf'>

    <legend id='8X2zf'><style id='8X2zf'><dir id='8X2zf'><q id='8X2zf'></q></dir></style></legend>

    <tfoot id='8X2zf'></tfoot>

    <i id='8X2zf'><tr id='8X2zf'><dt id='8X2zf'><q id='8X2zf'><span id='8X2zf'><b id='8X2zf'><form id='8X2zf'><ins id='8X2zf'></ins><ul id='8X2zf'></ul><sub id='8X2zf'></sub></form><legend id='8X2zf'></legend><bdo id='8X2zf'><pre id='8X2zf'><center id='8X2zf'></center></pre></bdo></b><th id='8X2zf'></th></span></q></dt></tr></i><div id='8X2zf'><tfoot id='8X2zf'></tfoot><dl id='8X2zf'><fieldset id='8X2zf'></fieldset></dl></div>
      <bdo id='8X2zf'></bdo><ul id='8X2zf'></ul>

        是否可以从 wwwroot 文件夹外部提供静态文件?

        时间:2023-07-12
      1. <tfoot id='Vs5Ci'></tfoot>
          <bdo id='Vs5Ci'></bdo><ul id='Vs5Ci'></ul>

                  <tbody id='Vs5Ci'></tbody>
                <i id='Vs5Ci'><tr id='Vs5Ci'><dt id='Vs5Ci'><q id='Vs5Ci'><span id='Vs5Ci'><b id='Vs5Ci'><form id='Vs5Ci'><ins id='Vs5Ci'></ins><ul id='Vs5Ci'></ul><sub id='Vs5Ci'></sub></form><legend id='Vs5Ci'></legend><bdo id='Vs5Ci'><pre id='Vs5Ci'><center id='Vs5Ci'></center></pre></bdo></b><th id='Vs5Ci'></th></span></q></dt></tr></i><div id='Vs5Ci'><tfoot id='Vs5Ci'></tfoot><dl id='Vs5Ci'><fieldset id='Vs5Ci'></fieldset></dl></div>

                <small id='Vs5Ci'></small><noframes id='Vs5Ci'>

                <legend id='Vs5Ci'><style id='Vs5Ci'><dir id='Vs5Ci'><q id='Vs5Ci'></q></dir></style></legend>

                  本文介绍了是否可以从 wwwroot 文件夹外部提供静态文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个具有以下结构的 ASP.NET MVC 6 项目:

                  I have an ASP.NET MVC 6 project with the following structure:

                  project/
                    wwwroot/
                    custom/
                    project.json
                  

                  我想将 custom 中的文件作为虚拟文件夹提供到 http://localhost/custom 中,而无需在开发过程中复制它们.

                  I want to serve files from custom as it if was a virtual folder into http://localhost/custom without having to copy them during development.

                  是否可以在没有来自 IIS 的虚拟文件夹的情况下在 vNext 中执行此操作(例如,使用 StaticFile 中间件)?

                  Is it possible to do this in vNext without a virtual folder from IIS (say, using the StaticFile middleware)?

                  推荐答案

                  使用中间件时可以在options对象上设置文件提供者.

                  You can set the file provider on the options object when using the middleware.

                  app.UseStaticFiles(new StaticFileOptions() {
                      FileProvider = new PhysicalFileProvider(@"C:PathToFiles"),
                      RequestPath = new PathString("/somepath")
                  })
                  

                  见:https://github.com/aspnet/StaticFiles/blob/master/src/Microsoft.AspNetCore.StaticFiles/Infrastructure/SharedOptions.cs#L44

                  https://github.com/aspnet/FileSystem/blob/dev/src/Microsoft.Extensions.FileProviders.Physical/PhysicalFileProvider.cs

                  这篇关于是否可以从 wwwroot 文件夹外部提供静态文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 .net 核心中使用多个结果集 下一篇:MVC.NET Core 中的条件验证(RequiredIf)

                  相关文章

                  1. <i id='huwez'><tr id='huwez'><dt id='huwez'><q id='huwez'><span id='huwez'><b id='huwez'><form id='huwez'><ins id='huwez'></ins><ul id='huwez'></ul><sub id='huwez'></sub></form><legend id='huwez'></legend><bdo id='huwez'><pre id='huwez'><center id='huwez'></center></pre></bdo></b><th id='huwez'></th></span></q></dt></tr></i><div id='huwez'><tfoot id='huwez'></tfoot><dl id='huwez'><fieldset id='huwez'></fieldset></dl></div>
                  2. <legend id='huwez'><style id='huwez'><dir id='huwez'><q id='huwez'></q></dir></style></legend>

                    <tfoot id='huwez'></tfoot>

                      <bdo id='huwez'></bdo><ul id='huwez'></ul>

                      <small id='huwez'></small><noframes id='huwez'>