本文整理汇总了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();
}
示例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();
}
示例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();
}
示例4: Configure
public void Configure(IApplicationBuilder app)
{
app.UseCultureReplacer();
app.UseInMemorySession();
app.UseMvcWithDefaultRoute();
}
示例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();
}
示例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!");
//});
}
示例7: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseErrorPage();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例12: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseMvcWithDefaultRoute();
app.UseStaticFiles();
}
示例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();
}
}
示例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();
}
示例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();
}