本文整理汇总了C#中IApplicationBuilder.UseStatusCodePagesWithReExecute方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseStatusCodePagesWithReExecute方法的具体用法?C# IApplicationBuilder.UseStatusCodePagesWithReExecute怎么用?C# IApplicationBuilder.UseStatusCodePagesWithReExecute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseStatusCodePagesWithReExecute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseStatusCodePagesWithReExecute("/Home/Error/{0}");
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例2: ConfigureErrorPages
/// <summary>
/// Configures the error pages for the application.
/// </summary>
/// <param name="application">The application.</param>
/// <param name="environment">The environment the application is running under. This can be Development,
/// Staging or Production by default.</param>
private static void ConfigureErrorPages(
IApplicationBuilder application,
IHostingEnvironment environment)
{
// Add the following to the request pipeline only in the development environment.
if (environment.IsDevelopment())
{
// When an error occurs, displays a detailed error page with full diagnostic information. It is unsafe
// to use this in production. See http://docs.asp.net/en/latest/fundamentals/diagnostics.html
application.UseDeveloperExceptionPage();
// When a database error occurs, displays a detailed error page with full diagnostic information. It is
// unsafe to use this in production. Uncomment this if using a database.
// application.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else // Add the following to the request pipeline only in the staging or production environments.
{
// Add error handling middle-ware which handles all HTTP status codes from 400 to 599 by re-executing
// the request pipeline for the following URL. '{0}' is the HTTP status code e.g. 404.
application.UseStatusCodePagesWithReExecute("/error/{0}/");
// Returns a 500 Internal Server Error response when an unhandled exception occurs.
application.UseInternalServerErrorOnException();
}
}
示例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.UseMvc();
}
示例4: 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.UseBrowserLink();
}
else
{
app.UseStatusCodePagesWithReExecute("/Error/Http{0}");
// Add Error handling middleware which catches all application specific errors and
// send the request to the following path or controller action.
app.UseExceptionHandler("/Error/Http500");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例5: 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();
}
}
示例6: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory logger)
{
logger.AddConsole();
logger.AddProvider(app.ApplicationServices.GetService<ISNSLoggerProvider>());
app.UseStatusCodePagesWithReExecute("/errors/{0}");
app.UseStaticFiles();
app.UseExceptionHandler("/errors/500");
app.UseMvc();
}
示例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)
{
app.UseStatusCodePagesWithReExecute("/StatusCodes/StatusCode{0}");
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Home/Error");
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
示例8: Configure
public void Configure(IApplicationBuilder app)
{
// Register how to generate response bodies for 400-599 status codes.
// This example ends up using the MVC ErrorsController.
app.UseStatusCodePagesWithReExecute("/errors/{0}");
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" });
});
}
示例9: ConfigureInternal
private void ConfigureInternal(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
app
.UseDeveloperExceptionPage()
.UseRuntimeInfoPage()
.UseBrowserLink();
else
app.UseExceptionHandler("/Errors/Error500");
app
.UseStatusCodePagesWithReExecute("/Errors/Error{0}")
.UseMvc();
}
示例10: Configure
// Configure is called after ConfigureServices is called.
public async void Configure(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerfactory,
SampleDataInitializer sampleData)
{
// Configure the HTTP request pipeline.
// Add the console logger.
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
app.UseStatusCodePagesWithReExecute("/Home/Error/{0}");
// Add the following to the request pipeline only in development environment.
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
{
//app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// send the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
// Add Sample Data
await sampleData.InitializeDataAsync();
}
示例11: Configure
/// <summary>Configure the HTTP request pipeline.</summary>
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
//Todo: Request pipeline.
//Exceptions
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Error");
app.UseStatusCodePagesWithReExecute("/Error/{0}");
//Files and pages
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute("default", "{Controller=Home}/{Action=Index}");
});
}
示例12: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
loggerFactory.AddConsole(LogLevel.Information);
}
else
{
app.UseStatusCodePagesWithReExecute("/Error/Status{0}");
app.UseErrorHandler("/Error");
loggerFactory.AddConsole(LogLevel.Warning);
}
app.UseReact(config =>
{
config
.AddScript("~/Content/js/socialfeed.jsx")
.SetUseHarmony(true)
.SetReuseJavaScriptEngines(false);
});
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
// All real routes are defined using attributes.
app.UseMvcWithDefaultRoute();
// Don't fall back to IIS on 404.
// TODO: This won't be needed from beta7 onwards: https://github.com/aspnet/Announcements/issues/54
app.Run(context =>
{
context.Response.StatusCode = 404;
return Task.FromResult(0);
});
// This is really not ideal, need to figure out a better way to do this.
// Based off http://stackoverflow.com/a/30762664/210370
UrlHelperExtensions.HttpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
}
示例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("/Exceptions/StatusCode{0}");
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Exceptions/ErrorPage");
app.UseStaticFiles();
//app.UseMvcWithDefaultRoute();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Exceptions",
template: "Home/ErrorPage",
defaults: new { controller = "Exceptions", action = "ErrorPage" }
);
routes.MapRoute(
name: "test",
template: "Recipes/StatusCode404",
defaults: new { controller = "Exceptions", action = "StatusCode404" }
);
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=index}/{id?}"
);
});
}
示例14: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseErrorPage();
}
else
{
// Add Error handling middleware which catches all application specific errors and
// send the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
app.UseStatusCodePagesWithReExecute("/Home/Status/{0}");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// 启用Session
app.UseSession();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
// Uncomment the following line to add a route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
}
示例15: 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(minLevel: LogLevel.Information);
app.UseStatusCodePagesWithReExecute("/StatusCodes/Statuscode{0}");
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Shared/Error");
app.UseStaticFiles();
app.UseIdentity();
app.UseMvcWithDefaultRoute();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Account}/{action=Login}");
});
}