本文整理汇总了C#中IApplicationBuilder.UseDeveloperExceptionPage方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseDeveloperExceptionPage方法的具体用法?C# IApplicationBuilder.UseDeveloperExceptionPage怎么用?C# IApplicationBuilder.UseDeveloperExceptionPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseDeveloperExceptionPage方法的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();
_logger = loggerFactory.CreateLogger("Test");
_logger.LogInformation("Starting Jacks logging");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseSignalR2();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
_dm = new DownloadManager(_logger, GlobalHost.ConnectionManager.GetHubContext<Scraper.Hubs.ChatHub>());
Console.CancelKeyPress += (s,e) => { _logger.LogInformation("CTRL+C detected - shutting down"); _dm.Stop(); };
}
示例2: 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();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseMultitenancy<AppTenant>();
app.UsePerTenant<AppTenant>((ctx, builder) =>
{
builder.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "Cookies",
LoginPath = new PathString("/account/login"),
AccessDeniedPath = new PathString("/account/forbidden"),
AutomaticAuthenticate = true,
AutomaticChallenge = true,
CookieName = $"{ctx.Tenant.Id}.AspNet.Cookies"
});
// only register for google if ClientId and ClientSecret both exist
var clientId = Configuration[$"{ctx.Tenant.Id}:GoogleClientId"];
var clientSecret = Configuration[$"{ctx.Tenant.Id}:GoogleClientSecret"];
if (!string.IsNullOrWhiteSpace(clientId) && !string.IsNullOrWhiteSpace(clientSecret))
{
builder.UseGoogleAuthentication(new GoogleOptions()
{
AuthenticationScheme = "Google",
SignInScheme = "Cookies",
ClientId = clientId,
ClientSecret = clientSecret
});
}
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例3: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
MappingsProvider.ConfigureMappings();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
try
{
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
//TODO better production release scenario
serviceScope.ServiceProvider.GetService<AppDbContext>().Database.Migrate();
}
}
catch
{
}
}
app.UseStatusCodePagesWithRedirects("~/Home/Error/{0}");
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
app.EnsureRolesCreated();
var staticProvidersConfigurator = app.ApplicationServices.GetService<IStaticProvidersConfigurator>();
staticProvidersConfigurator.Init();
app.UseCookieAuthentication((p) => new CookieAuthenticationOptions
{
LoginPath = "/Account/Login"
});
app.UseMvc();
}
示例4: Configure
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
Log.Logger =
new LoggerConfiguration()
.MinimumLevel.Error()
.WriteTo.TextWriter(System.Console.Out)
.WriteTo.RollingFile(@"C:\temp\TSWebLog-{Date}.txt")
.CreateLogger();
loggerFactory.AddSerilog();
app.UseStaticFiles();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
}
示例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(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler(options =>
options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseGlimpse();
app.UseMvc(routes =>
{
routes.MapRoute("default",
"{controller=Home}/{action=Index}/{id?}");
routes.MapRoute("spa-fallback",
"{*anything}",
new { controller = "Home", action = "Index" });
routes.MapWebApiRoute("defaultApi",
"api/{controller}/{id?}");
});
}
示例6: 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.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMiddleware<Middleware.FilterLinkProbes>();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
app.UseIISPlatformHandler();
if (!env.IsDevelopment())
{
// This has to come after UseIISPlatformHandler(), otherwise
// the request context will always think it's HTTP
app.UseMiddleware<Middleware.EnforceHttps>();
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{action=Set}",
defaults: new {controller = "Home"});
});
}
示例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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
var section = Configuration.GetSection("MongoDB");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseCors("AllowAll");
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name:"api",
template: "api/{controller}/{id?}"
);
});
}
示例9: 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();
}
示例10: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
loggerFactory
.AddConsole(Configuration.GetSection("Logging"))
.AddDebug();
// Use the Default files ['index.html', 'index.htm', 'default.html', 'default.htm']
app.UseDefaultFiles()
.UseStaticFiles()
.UseIISPlatformHandler()
.UseMvc();
// Setup a generic Quotes API EndPoint
app.Map("/api/quotes", (config) =>
{
app.Run(async context =>
{
var quotes = "{ \"quotes\":" +
" [ { \"quote\": \"Duct tape is like the force. It has a light side, a dark side, and it holds the universe together.\", \"author\":\"Oprah Winfrey\"} ]" +
"}";
context.Response.ContentLength = quotes.Length;
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(quotes);
});
});
}
示例11: Configure
public void Configure(IApplicationBuilder app)
{
app.UseApplicationInsightsRequestTelemetry();
app.UseDeveloperExceptionPage(new ErrorPageOptions());
app.UseApplicationInsightsExceptionTelemetry();
app.Use(next =>
{
return async context =>
{
if (context.Request.GetUri().ToString().Contains("Exception"))
{
throw new InvalidOperationException();
}
else if (context.Request.GetUri().PathAndQuery == "/")
{
await context.Response.WriteAsync("Hello!");
}
else if (context.Request.GetUri().ToString().Contains("Mixed"))
{
TelemetryClient telemetryClient = (TelemetryClient)context.RequestServices.GetService(typeof(TelemetryClient));
telemetryClient.TrackEvent("GetContact");
telemetryClient.TrackMetric("ContactFile", 1);
telemetryClient.TrackTrace("Fetched contact details.", SeverityLevel.Information);
await context.Response.WriteAsync("Hello!");
}
else
{
await next(context);
}
};
});
}
示例12: Configure
public void Configure(IApplicationBuilder app)
{
var password = config["password"];
if (config.Get<bool>("RecreateDatabase"))
{
var context = app.ApplicationServices.GetService<Models.BlogDataContext>();
context.Database.EnsureDeleted();
System.Threading.Thread.Sleep(2000);
context.Database.EnsureCreated();
}
app.UseIdentity();
if (config.Get<bool>("debug"))
{
app.UseDeveloperExceptionPage();
app.UseRuntimeInfoPage();
}
else
{
app.UseExceptionHandler("/home/error");
}
app.UseMvc(routes => routes.MapRoute(
"Default", "{controller=Home}/{action=Index}/{id?}"));
app.UseFileServer();
}
示例13: 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();
}
示例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(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseApplicationInsightsRequestTelemetry();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "mainRoute",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapWebApiRoute(
name: "api",
template: "api/{controller}/{action}/{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(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = "Cookies";
options.LoginPath = new Microsoft.AspNet.Http.PathString("/Account/Login");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}