zoukankan      html  css  js  c++  java
  • Microsoft.Owin 使用 文件服务

    添加引用:
    <package id="Microsoft.Owin" version="4.0.1" targetFramework="net461" />
    <package id="Microsoft.Owin.FileSystems" version="4.0.1" targetFramework="net461" />
    <package id="Microsoft.Owin.Hosting" version="4.0.2" targetFramework="net461" />
    <package id="Microsoft.Owin.StaticFiles" version="4.0.1" targetFramework="net461" />
     
    appBuilder.UseFileServer(new FileServerOptions()
                {
                    RequestPath = PathString.Empty,
                    FileSystem = new PhysicalFileSystem(@".")
                });
    
                appBuilder.UseStaticFiles("/Views");
                appBuilder.UseStaticFiles("/Scripts");
                appBuilder.UseStaticFiles("/js");
                appBuilder.UseStaticFiles("/Content");
    
                // Configure Web API for self-host. 
                HttpConfiguration config = new HttpConfiguration();
    
                //  Enable attribute based routing
                //  http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
                config.MapHttpAttributeRoutes();
    
                // Remove the XML formatter
                config.Formatters.Remove(config.Formatters.XmlFormatter);
    
                config.Routes.MapHttpRoute(
                    name: "AfterglowAPI",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
    
                appBuilder.UseWebApi(config);
            } 

    效果:

    参考:https://chris.59north.com/post/What-is-OWIN-and-what-is-it-doing-in-my-new-ASPNET-MVC-project

    https://mirkomaggioni.com/2016/09/11/owin-middleware-for-static-files/

    https://odetocode.com/blogs/scott/archive/2014/02/10/building-a-simple-file-server-with-owin-and-katana.aspx

    https://github.com/aspnet/AspNetKatana/tree/dev/src

    https://beginor.github.io/2015/12/28/owin-static-file-middleware.html

     http://johnatten.com/2015/01/04/asp-net-understanding-owin-katana-and-the-middleware-pipeline/

  • 相关阅读:
    看动画学算法之:排序-归并排序
    看动画学算法之:排序-选择排序
    【电脑】第3期:电脑如何打开上帝模式?
    限时删除!能挑战idm的下片神器,最快33M/S
    基本类型计算中浮点数的错误
    字符数组的toString方法打印的是地址值
    boolean类型的成员变量自动生成get方法的问题
    多态的使用
    抽象类和接口的使用关系
    接口的注意事项
  • 原文地址:https://www.cnblogs.com/micro-chen/p/11813307.html
Copyright © 2011-2022 走看看