当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.MapPath方法代码示例

本文整理汇总了C#中IAppBuilder.MapPath方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.MapPath方法的具体用法?C# IAppBuilder.MapPath怎么用?C# IAppBuilder.MapPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.MapPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configuration

        public void Configuration(IAppBuilder app)
        {
            // app.UseFilter(req => req.TraceOutput.WriteLine(
            //    "{0} {1}{2} {3}",
            //    req.Method, req.PathBase, req.Path, req.QueryString));

            app.UseErrorPage();
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.UseType<CanonicalRequestPatterns>();

            app.UseFileServer(opt => opt.WithPhysicalPath("Public"));

            app.MapPath("/static-compression", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.WithPhysicalPath("Public");
                }));

            app.MapPath("/danger", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.StaticFileOptions.ServeUnknownFileTypes = true;
                }));

            app.UseDiagnosticsPage("/testpage");
        }
开发者ID:tkggand,项目名称:katana,代码行数:31,代码来源:Startup.cs

示例2: Configuration

        public void Configuration(IAppBuilder builder)
        {
            builder.UseType<AddBreadCrumbMiddleware>("start-of-the-line");

            builder.MapPath("/branch1", builder1 =>
            {
                builder1.UseType<AddBreadCrumbMiddleware>("took-branch1");

                // Nesting paths, e.g. /branch1/branch2
                builder1.MapPath("/branch2", builder2 =>
                {
                    builder2.UseType<AddBreadCrumbMiddleware>("took-branch2");
                    builder2.UseType<DisplayBreadCrumbs>();
                });

                MapIfIE(builder1);
                builder1.UseType<DisplayBreadCrumbs>();
            });

            // Only full segments are matched, so /branch1 does not match /branch100
            builder.MapPath("/branch100", builder1 =>
            {
                builder1.UseType<AddBreadCrumbMiddleware>("took-branch100");
                builder1.UseType<DisplayBreadCrumbs>();
            });

            MapIfIE(builder);

            builder.UseType<AddBreadCrumbMiddleware>("no-branches-taken");
            builder.UseType<DisplayBreadCrumbs>();
        }
开发者ID:srihari-sridharan,项目名称:Programming-Playground,代码行数:31,代码来源:Startup.cs

示例3: Configuration

        public void Configuration(IAppBuilder builder)
        {
            // Configure SignalR DI
            GlobalHost.DependencyResolver.Register(typeof (IDocumentStore), () => _documentStore);

            // Nancy DI container is configured in its bootstrapper
            var sampleBootstrapper = new SampleBootstrapper(_documentStore);

            // Note: it's perfectly viable to have an over-arching single application container
            // and configure signalr and nancy to use it.

            builder
                .MapPath("/fault",
                         faultBuilder => faultBuilder
                            .UseShowExceptions()
                            .UseHandler((request, response) => { throw new Exception("oops!"); }))
                .MapPath("/files",
                         siteBuilder => siteBuilder
                            .UseBasicAuth((user, pass) => Task.FromResult(pass == "damo"))
                            .UseDenyAnonymous()
                            .UseDirectoryBrowser(@"c:\"))
                .MapPath("/scripts", scriptsBuilder => scriptsBuilder.UseFileServer("scripts"))
                .MapPath("/site", siteBuilder => siteBuilder.UseNancy(sampleBootstrapper))
                .MapHubs()
                .UseTestPage();
        }
开发者ID:serbrech,项目名称:DublinAltNetOwin,代码行数:26,代码来源:Startup.cs

示例4: Configuration

 // Nuget package: Microsoft.Owin.Mapping
 public void Configuration(IAppBuilder builder)
 {
     builder
         .MapPath("/api", b => b.UseHandler((request, response) => response.StatusCode = 302))
         .MapPath("/admin", b => { /* etc */})
         .MapPredicate(env => true, b => { /* etc */});
 }
开发者ID:Eugene1982,项目名称:NancySignalrOwin,代码行数:8,代码来源:_06_MappingRouting.cs

示例5: SetupMiddleware

        private static void SetupMiddleware(IApplicationSettings settings, IAppBuilder app)
        {
            if (settings.ProxyImages)
            {
                app.MapPath("/proxy", subApp => subApp.Use(typeof(ImageProxyHandler), settings));
            }

            app.UseStaticFiles();
        }
开发者ID:bartsipes,项目名称:JabbR,代码行数:9,代码来源:Startup.cs

示例6: SetupMiddleware

 private static void SetupMiddleware(IAppBuilder app)
 {
     app.MapPath("/proxy", subApp => subApp.Use(typeof(ImageProxyHandler)));
     app.UseStaticFiles();
 }
开发者ID:arri-cc,项目名称:JabbR,代码行数:5,代码来源:Startup.cs

示例7: SetupNancy

 private static void SetupNancy(IKernel kernel, IAppBuilder app)
 {
     var bootstrapper = new JabbRNinjectNancyBootstrapper(kernel);
     app.MapPath("/auth", subApp => subApp.UseNancy(bootstrapper));
 }
开发者ID:danzel,项目名称:JabbR,代码行数:5,代码来源:Startup.cs

示例8: Configuration


//.........这里部分代码省略.........
            dfo.DefaultFileNames.Add("index.html");
            dfo.FileSystem = fs;

            var sfo = new StaticFileOptions
                      {
                          FileSystem = fs
                      };
            var loginSfo = new StaticFileOptions
                           {
                               FileSystem = loginFs
                           };

            builder.SetDataProtectionProvider(new DpapiDataProtectionProvider());
            var formsAuthenticationProvider = new FormsAuthenticationProvider();

            formsAuthenticationProvider.OnValidateLogin = context =>
            {
                Console.WriteLine("Validating Login");
                Console.WriteLine("================");
                Console.WriteLine("  Context.AuthType: " + context.AuthenticationType);
                Console.WriteLine("  Context.Identity: " + (context.Identity != null ? context.Identity.Name : "Not set"));
                Console.WriteLine("  Context.Environment:");

                var response = new OwinResponse(context.Environment);

                if (LoginContext.GetIsLoginRequest(context.Environment))
                {
                    // Need to retrieve username and password from environment b/c it doesn't
                    // come through in the context (even though the context constructor accepts them)

                    var username = context.Environment["formsauthn.username"].ToString();
                    var password = context.Environment["formsauthn.password"].ToString();
                    var remember = bool.Parse(context.Environment["formsauthn.remember"].ToString());

                    Console.WriteLine("  Request.Username: " + username);
                    Console.WriteLine("  Request.Password: " + password);
                    Console.WriteLine("  Request.Remember: " + remember);

                    if (username == password)
                    {
                        var identity = new ClaimsIdentity(
                            new GenericIdentity(username, context.AuthenticationType),
                            new[]
                            {
                                new Claim(ClaimTypes.IsPersistent, remember.ToString())
                            }
                            );

                        // I assumed that this would take care of populating the cookie for me... but not so much.
                        context.Signin(identity);

                        var msg = "Access granted.";
                        Console.WriteLine(msg);
                        var msgBytes = Encoding.UTF8.GetBytes(msg);
                        return response.Body.WriteAsync(msgBytes, 0, msgBytes.Length);
                    }
                    else
                    {
                        var msg = "Access denied.  Try with username=password";
                        Console.WriteLine(msg);
                        var msgBytes = Encoding.UTF8.GetBytes(msg);
                        return response.Body.WriteAsync(msgBytes, 0, msgBytes.Length);
                    }
                }
                else
                {
                    foreach (var item in context.Environment)
                    {
                        Console.WriteLine("  {0}={1}",
                                          item.Key,
                                          item.Value != null
                                              ? (item.Value is string ? (string) item.Value : item.Value.GetType().FullName)
                                              : "Not set"
                            );
                    }
                }

                return response.Body.WriteAsync(new byte[] { }, 0, 0);
            };

            builder.UseFormsAuthentication(
                new FormsAuthenticationOptions
                {
                    CookieHttpOnly = true,
                    CookieName = "AuthCookie",
                    CookiePath = "/",
                    CookieSecure = false,
                    LoginPath = "/login/",
                    ExpireTimeSpan = TimeSpan.FromHours(1),
                    ReturnUrlParameter = "returnUrl",
                    SlidingExpiration = true,
                    Provider = formsAuthenticationProvider
                }
            );
            builder.UseApplicationSignInCookie();
            builder.UseDefaultFiles(dfo);
            builder.UseErrorPage();
            builder.MapPath("/login", loginBuilder => loginBuilder.UseProcessLoginPostback(formsAuthenticationProvider).UseStaticFiles(loginSfo));
            builder.UseDenyAnonymous().UseStaticFiles(sfo);
        }
开发者ID:BlissettDMB,项目名称:OwinFormsAuthnTest,代码行数:101,代码来源:Program.cs

示例9: Configuration

 public void Configuration(IAppBuilder builder)
 {
     builder.MapPath("/admin", adminBuilder => adminBuilder
                                 .DenyNonLocalRequests()
                                 .UseHandler((request, response) => response.Write("You're in.")));
 }
开发者ID:Eugene1982,项目名称:NancySignalrOwin,代码行数:6,代码来源:_09_CustomMiddleware.cs


注:本文中的IAppBuilder.MapPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。