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


C# IApplicationBuilder.UseIdentity方法代码示例

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


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

示例1: Configure

    public async void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory loggerFactory)
    {
            loggerFactory.AddDebug(LogLevel.Warning);

            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap<Trip, TripViewModel>().ReverseMap();
                config.CreateMap<Stop, StopViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
              {
                config.MapRoute(
                  name: "Default",
                  template: "{controller}/{action}/{id?}",
                  defaults: new { controller = "App", action = "Index" }
                  );
      });

      await seeder.EnsureSeedData();
    }
开发者ID:MattPuzey,项目名称:Tutorials,代码行数:25,代码来源:Startup.cs

示例2: Configure

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

            app.UseIdentity();

            app.UseSession();

            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    name: "leaveComment",
                //    template: "Blog/LeaveComment",
                //    defaults: new { controller = "Blog", action = "LeaveComment" });

                routes.MapRoute(
                    name: "findPostById",
                    template: "Blog/{id}",
                    defaults: new { controller = "Blog", action = "ViewPost" });

                routes.MapRoute(
                    name: "tagged",
                    template: "Blog/Tagged/{tag}",
                    defaults: new { controller = "Blog", action = "Tagged" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

            });
        }
开发者ID:gwartnes,项目名称:Blogness,代码行数:31,代码来源: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)
    {
      app.UseStatusCodePagesWithReExecute("/Error/{0}");

      // Add the following to the request pipeline only in development environment.
      if (_env.IsDevelopment())
      {
        loggerFactory.AddDebug(LogLevel.Information);
        app.UseDeveloperExceptionPage();
        app.UseDatabaseErrorPage(options => options.ShowExceptionDetails = true);
      }
      else
      {
        // Add Error handling middleware which catches all application specific errors and
        // send the request to the following path or controller action.
        loggerFactory.AddDebug(LogLevel.Error);
        app.UseExceptionHandler("/Error");
      }

      app.UseIISPlatformHandler();
      app.UseStaticFiles();

      app.UseIdentity();
      app.UseMvc();

    }
开发者ID:mmillican,项目名称:WilderBlog,代码行数:28,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            // Configure Session.
            app.UseSession();

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseIdentity();

            // Add login providers (Microsoft/AzureAD/Google/etc).  This must be done after `app.UseIdentity()`
            app.AddLoginProviders(new ConfigurationLoginProviders(Configuration.GetSection("Authentication")));

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}",
                    defaults: new { action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the PartsUnlimited sample data
            SampleData.InitializePartsUnlimitedDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:Ranireddy,项目名称:PartsUnlimited,代码行数:35,代码来源:Startup.cs

示例5: Configure

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

            app.ApplicationServices.GetRequiredService<OkMidnightDbContext>().EnsureSeedData();

            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();

            app.UseIdentity();
            app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions
            {
                ClientId = _configuration["Authentication:Microsoft:ClientId"],
                ClientSecret = _configuration["Authentication:Microsoft:ClientSecret"]
            });

            app.UseMvc(routes => {
                routes.MapRoute("home", "{action=Index}/{id?}/{name?}", new { controller = "Home" });
                routes.MapRoute("admin", "admin/{controller=Categories}/{action=Index}/{id?}");
                routes.MapRoute("account", "account/{action=Index}", new { controller = "Account" });
                routes.MapRoute("picker", "picker/{name}", new { controller = "Picker", action = "Index" });
            });

            app.UseHangfireServer();
            app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new LoggedUserAuthorizationFilter() } });
        }
开发者ID:kbok,项目名称:OkMidnight,代码行数:28,代码来源: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, ILoggerFactory loggerFactory, IHostingEnvironment env)
        {
            // Need to hook this up before the other middleware is hooked up
            // this does not use the extension method
            // app.UseMiddleware<HeaderMiddleware>(new HeaderOptions {HeaderName="X-Powered-By", HeaderValue="ASPNET_CORE" });
            //using the extension method
            app.UseCustomHeader(new HeaderOptions { HeaderName = "X-TODO-Powered-By", HeaderValue = "ASPNET_CORE" });

            // without static files not event html or images will be served up
            app.UseStaticFiles();

            // Add another custom middle ware that adds the execution time as a header
            app.UsePipelineTimer();
            // Via diagnostics.. shows the new yellow screen of death

            // Need to add .adddebug and  console logging level should watch if you want debug messages to popup
            loggerFactory.AddConsole(LogLevel.Debug);
                loggerFactory.AddDebug();

                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();

            //Note order is important use identity has to come before you call
            // external login  provider else it won't work
            app.UseIdentity();
            app.UseTODOMVCOAuthAuthentication(Configuration);

            app.UseMvc(routes =>
             routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}/{type?}"
                 ));
        }
开发者ID:jmurkoth,项目名称:TODOMVC,代码行数:34,代码来源:StartupAzureDev.cs

示例7: 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)
        {
            Console.WriteLine(Configuration["secretThing"]);
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment()) {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes => {
                routes.MapRoute(
                    name: "default",
                    template: "{*path}",
                    defaults: new { controller = "Home", action = "Index" }
                );
            });

            // initialize sample data
            SampleData.Initialize(app.ApplicationServices).Wait();
        }
开发者ID:CCFS-Hou,项目名称:ComicStore,代码行数:33,代码来源:Startup.cs

示例8: 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, BlogContextDataSeed dataSeed)
		{
			loggerFactory.AddConsole(Configuration.GetSection("Logging"));
			loggerFactory.AddDebug();

			app.UseIdentity();

			//app.UseIISPlatformHandler();

			if (env.IsDevelopment())
				app.UseDeveloperExceptionPage();

			app.UseCookieAuthentication(options =>
			{
				options.LoginPath = new PathString("/Auth/Login");
			});

			app.UseStaticFiles();

			app.UseMvc(config =>
			{
				config.MapRoute(
					name: "Default",
					template: "{controller}/{action}/{id?}",
					defaults: new {controller = "App", action = "Index"});
			});

			_dataStartup.Configure(app, dataSeed);
		}
开发者ID:AlexanderYakshin,项目名称:Blog,代码行数:30,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory)
        {
            // Configure logging
            // https://docs.asp.net/en/latest/fundamentals/logging.html
            factory.AddConsole(Configuration.GetSection("Logging"));
            factory.AddDebug();

            // Serve static files
            // https://docs.asp.net/en/latest/fundamentals/static-files.html
            app.UseStaticFiles();

            // Enable external authentication provider(s)
            // https://docs.asp.net/en/latest/security/authentication/sociallogins.html
            app.UseIdentity();

            if (!string.IsNullOrEmpty(Configuration["Authentication:Facebook:AppId"]))
            {
                app.UseFacebookAuthentication(new FacebookOptions
                {
                    AppId = Configuration["Authentication:Facebook:AppId"],
                    AppSecret = Configuration["Authentication:Facebook:AppSecret"],
                    Scope = { "email" },
                    Fields = { "name", "email" },
                    SaveTokens = true,
                });
            }

            // Configure ASP.NET MVC
            // https://docs.asp.net/en/latest/mvc/index.html
            app.UseMvc(routes =>
            {
                routes.MapRoute("default", "{*url}", new { controller = "Home", action = "Index" });
            });
        }
开发者ID:cybernetics,项目名称:aspnet-starter-kit,代码行数:34,代码来源:Startup.cs

示例10: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
        {
            loggerfactory.AddConsole(minLevel: LogLevel.Warning);

            if (env.IsEnvironment("Development")) {
                ////app.UseBrowserLink();
                app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 10 });
                app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
            } else {
                app.UseErrorHandler("/Home/Error");
            }

            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline.
            app.UseIdentity();

            if (env.IsEnvironment("Development")) {
                app.UseHardCodedAuthentication();
            } else {
                // Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
                // For more information see http://go.microsoft.com/fwlink/?LinkID=532715
                // app.UseFacebookAuthentication();
                // app.UseGoogleAuthentication();
                // app.UseMicrosoftAccountAuthentication();
                // app.UseTwitterAuthentication();
            }

            app.UseMvc(routes => {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
开发者ID:jonfreeland,项目名称:HardCodedAuthenticationMiddleware,代码行数:35,代码来源:Startup.cs

示例11: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseIdentity();
     app.UseIISPlatformHandler();
     app.UseFileUpload();
     app.UseMvcWithDefaultRoute();
 }
开发者ID:CodeCombLLC,项目名称:MobileOperation,代码行数:7,代码来源:Startup.cs

示例12: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddDebug(minLevel: LogLevel.Warning);

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

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseStaticFiles();

            app.UseIdentity();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" }
                    );
            });
        }
开发者ID:hydrangenius,项目名称:CheckMyExpenses,代码行数:29,代码来源: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(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment()) {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            } else {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            

            app.UseMvc(routes => {
                routes.MapRoute(name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}/{id?}",
                    defaults: new { controller = "Dashboard", action = "Index" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:LupinIIIit,项目名称:Splendor.Web,代码行数:29,代码来源: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, 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

示例15: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseIdentity();

            // Add the following to the request pipeline only in development environment.
            if (env.IsEnvironment("Development"))
            {
                app.UseBrowserLink();
            }
            /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();

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


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