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


C# IApplicationBuilder.UseMvcWithDefaultRoute方法代码示例

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


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

示例1: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();

            app.UseCors(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());

            // IdentityServer3 hardcodes the audience as '{host-address}/resources'.
            // It is suggested to do the validation on scopes.
            // That's why audience validation is disabled with 'ValidateAudience = false' below.
            app.UseJwtBearerAuthentication(options =>
            {
                options.Authority = "http://localhost:44300/";
                options.AutomaticAuthentication = true;
                options.TokenValidationParameters.ValidateAudience = false;

                if (_hostingEnv.IsDevelopment())
                {
                    options.ConfigurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(
                        metadataAddress: $"{options.Authority}.well-known/openid-configuration",
                        configRetriever: new OpenIdConnectConfigurationRetriever(),
                        docRetriever: new HttpDocumentRetriever { RequireHttps = false }
                    );
                }
            });

            app.UseMiddleware<RequiredScopesMiddleware>(new List<string> { "write" });
            app.UseMvcWithDefaultRoute();
        }
开发者ID:syoguran,项目名称:ModernShopping,代码行数:28,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseDeveloperExceptionPage();
            app.UseStaticFiles();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = "Cookies",
                AutomaticAuthenticate = true
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            {
                AuthenticationScheme = "oidc",
                SignInScheme = "Cookies",

                Authority = "https://demo.identityserver.io",
                PostLogoutRedirectUri = "http://localhost:3308/",
                ClientId = "hybrid",
                ClientSecret = "secret",
                ResponseType = "code id_token",
                GetClaimsFromUserInfoEndpoint = true,
                SaveTokens = true
            });

            app.UseMvcWithDefaultRoute();
        }
开发者ID:ReinhardHsu,项目名称:AspNetCoreSecuritySamples,代码行数:32,代码来源:Startup.cs

示例3: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
            ILoggerFactory loggerFactory)
        {
            // The hosting environment can be found in a project's properties -> DEBUG or in launchSettings.json.
            if (_hostingEnvironment.IsDevelopment())
            {
                // The exception page is only shown if the app is in development mode.
                app.UseDeveloperExceptionPage();
            }

            // This middleware makes sure our app is correctly invoked by IIS.
            app.UseIISPlatformHandler();

            // Add the MVC middleware service above first. Then use said middleware in this method.
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller}/{action}/{id}",
            //        defaults: new { controller = "Home", action = "Index" }
            //    );
            //});

            app.UseMvcWithDefaultRoute();

            // Always remember to add the static files middleware or the images from JavaScript or CSS 
            // won't be served.
            app.UseStaticFiles();

            // Whenever HTTP status codes like 404 arise, the below middleware will display them on the page.
            app.UseStatusCodePages();
        }
开发者ID:jimxshaw,项目名称:samples-csharp,代码行数:33,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseCultureReplacer();

            app.UseInMemorySession();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:7,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseDeveloperExceptionPage();
            app.UseStaticFiles();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = "Cookies",
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,

                LoginPath = new PathString("/account/login")
            });

            app.UseClaimsTransformation(context =>
            {
                if (context.Principal.Identity.IsAuthenticated)
                {
                    context.Principal.Identities.First().AddClaim(new Claim("now", DateTime.Now.ToString()));
                }

                return Task.FromResult(context.Principal);
            });

            app.UseMvcWithDefaultRoute();
        }
开发者ID:ReinhardHsu,项目名称:AspNetCoreSecuritySamples,代码行数:29,代码来源:Startup.cs

示例6: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();

            app.UseMvcWithDefaultRoute();

            app.UseStaticFiles(new StaticFileOptions()
            {
                OnPrepareResponse = (context) =>
                {
                    var headers = context.Context.Response.GetTypedHeaders();
                    headers.CacheControl = new CacheControlHeaderValue()
                    {
                        MaxAge = TimeSpan.FromDays(1)
                    };
                }
            });

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});



        }
开发者ID:DannyvanderKraan,项目名称:StaticFilesAndMvc6Problem,代码行数:27,代码来源:Startup.cs

示例7: Configure

    public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole();
		app.UseErrorPage();
		app.UseStaticFiles();
		app.UseMvcWithDefaultRoute();        
    }
开发者ID:kheerthiimandi,项目名称:asp.net5-cloudant,代码行数:7,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder app)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            app.UseIISPlatformHandler();

            app.UseCookieAuthentication(options =>
            {
                options.AuthenticationScheme = "Cookies";
                options.AutomaticAuthenticate = true;
            });

            app.UseOpenIdConnectAuthentication(options =>
            {
                options.AutomaticChallenge = true;
                options.AuthenticationScheme = "Oidc";
                options.SignInScheme = "Cookies";

                options.Authority = "http://localhost:18942/";
                options.RequireHttpsMetadata = false;

                options.ClientId = "mvc6";
                options.ResponseType = "id_token token";

                options.Scope.Add("openid");
                options.Scope.Add("email");
                options.Scope.Add("api1");
            });

            app.UseDeveloperExceptionPage();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:RobGibbens,项目名称:IdentityServer3.Samples,代码行数:32,代码来源:Startup.cs

示例9: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();

            app.UseMvcWithDefaultRoute();

        }
开发者ID:ChujianA,项目名称:aspnetcore-doc-cn,代码行数:8,代码来源:Startup.cs

示例10: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;

            app.UseCookieAuthentication(options =>
            {
                options.LoginPath = "/account/login";

                options.AuthenticationScheme = "Cookies";
                options.AutomaticAuthentication = true;
            }, "main");

            app.UseCookieAuthentication(options =>
            {
                options.AuthenticationScheme = "Temp";
                options.AutomaticAuthentication = false;
            }, "external");

            app.UseGoogleAuthentication(options =>
            {
                options.ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com";
                options.ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo";

                options.AuthenticationScheme = "Google";
                options.SignInScheme = "Temp";
            });

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:okusnadi,项目名称:AspNet5TemplateExternalWithCallback,代码行数:30,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(LogLevel.Trace);
            loggerFactory.AddDebug(LogLevel.Trace);

            app.UseDeveloperExceptionPage();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = "Temp",
                AutomaticAuthenticate = false,
                AutomaticChallenge = false
            });

            app.UseGoogleAuthentication(new GoogleOptions
            {
                AuthenticationScheme = "Google",
                SignInScheme = "Temp",
                ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com",
                ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo"
            });

            app.UseIdentityServer();

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:wondertrap,项目名称:AspNet5IdentityServerAngularImplicitFlow,代码行数:27,代码来源:Startup.cs

示例12: Configure

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (env.IsDevelopment())
         app.UseDeveloperExceptionPage();
     app.UseMvcWithDefaultRoute();
     app.UseStaticFiles();
 }
开发者ID:NonFactors,项目名称:MVC6.Grid.Web,代码行数:7,代码来源:Startup.cs

示例13: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, 
            ILoggerFactory loggerFactory)
        {
            
            loggerFactory.AddConsole(LogLevel.Error);
            {
                app.UseIISPlatformHandler();

                app.UseStatusCodePagesWithReExecute("/StatusCodes/StatusCode{0}");

                if (env.IsDevelopment())
                    app.UseDeveloperExceptionPage();
                else
                    app.UseExceptionHandler("/Home/Error");

                app.UseStaticFiles();
                app.UseIdentity();
                /*app.UseMvc(routes =>
                {
                    /*routes.MapRoute(
                        name: "reg",
                        template: "Konto/Skapa",
                        defaults: new { controller = "Account", Action = "Registration" }
                        );
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id}");
                });*/
                app.UseMvcWithDefaultRoute();

            }
        }
开发者ID:Wisarut11,项目名称:FamilyTree,代码行数:33,代码来源:Startup.cs

示例14: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseStaticFiles();

            app.UseMvc(routes =>
              routes.MapRoute(
                name: "default",
                template: "{controller}/{action}/{id?}",
                defaults: new { controller = "Home", action = "Index" })
              .MapRoute(
                name: "language",
                template: "{language}/{controller}/{action}/{id?}",
                defaults: new { controller = "Home", action = "Index" },
                constraints: new { language = @"(en)|(de)" })
              .MapRoute(
                name: "multipleparameters",
                template: "{controller}/{action}/{x}/{y}",
                defaults: new { controller = "Home", action = "Add" },
                constraints: new { x = @"\d", y = @"\d" }
                ));


            app.UseMvcWithDefaultRoute();

        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:29,代码来源:Startup.cs

示例15: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseIISPlatformHandler();
            app.UseDeveloperExceptionPage();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                LoginPath = "/account/login",

                AuthenticationScheme = "Cookies",
                AutomaticAuthenticate = true,
                AutomaticChallenge = true
            });

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = "Temp",
                AutomaticAuthenticate = false
            });

            app.UseGoogleAuthentication(new GoogleOptions
            {
                ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com",
                ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo",

                AuthenticationScheme = "Google",
                SignInScheme = "Temp"
            });

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
开发者ID:freemsly,项目名称:AspNet5TemplateExternalWithCallback,代码行数:32,代码来源:Startup.cs


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