本文整理汇总了C#中ILoggerFactory.AddProvider方法的典型用法代码示例。如果您正苦于以下问题:C# ILoggerFactory.AddProvider方法的具体用法?C# ILoggerFactory.AddProvider怎么用?C# ILoggerFactory.AddProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILoggerFactory
的用法示例。
在下文中一共展示了ILoggerFactory.AddProvider方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program
public Program(IRuntimeEnvironment runtimeEnvironment)
{
_loggerFactory = new LoggerFactory();
var commandProvider = new CommandOutputProvider(runtimeEnvironment);
_loggerFactory.AddProvider(commandProvider);
}
示例2: Program
public Program()
{
_loggerFactory = new LoggerFactory();
var commandProvider = new CommandOutputProvider();
_loggerFactory.AddProvider(commandProvider);
}
示例3: 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();
}
示例4: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
// Configure the HTTP request pipeline.
// Add the console logger.
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
loggerfactory.AddProvider(new SqlLoggerProvider());
// Add the following to the request pipeline only in development environment.
if (env.IsEnvironment("Development"))
{
app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
app.EnsureMigrationsApplied();
app.EnsureSampleData();
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends 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();
if (_useFacebookAuth)
{
app.UseFacebookAuthentication();
}
if (_useGoogleAuth)
{
app.UseGoogleAuthentication();
}
app.EnsureRolesCreated();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
// Uncomment the following line to add a route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
}
示例5: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//this is the magic line
loggerFactory.AddProvider(new MyLoggerProvider());
app.UseIISPlatformHandler();
app.UseMvc();
}
示例6: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
loggerFactory.AddProvider(new MyLoggerProvider2());
app.UseStaticFiles();
app.UseMvc();
//Creates the database & populates the sample data
SampleData.InitializeWeatherEventDatabaseAsync(app.ApplicationServices).Wait();
}
示例7: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
Config.ApplicationBase = env.WebRootPath;
var webConfigPath = Path.Combine(Config.ApplicationBase, "web.config");
var logRootDirPath = Config.LoggingDirectory ?? Path.Combine(Config.ApplicationBase, "logs");
loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddProvider(new Log4NetLoggerProvider(new FileInfo(webConfigPath), new DirectoryInfo(logRootDirPath)));
app.UseWebSockets();
app.UseMvc();
}
示例8: CreateHost
public static IOrchardHost CreateHost(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddProvider(new TestLoggerProvider());
app.UseMiddleware<OrchardContainerMiddleware>();
app.UseMiddleware<OrchardShellHostMiddleware>();
// Think this needs to be inserted in a different part of the pipeline, possibly
// when DI is created for the shell
app.UseMiddleware<OrchardRouterMiddleware>();
return app.ApplicationServices.GetService<IOrchardHost>();
}
示例9: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddProvider(new DebugLoggerProvider());
app.UseBasicAuth(options =>
{
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
options.AuthenticateCredential = authInfo =>
{
if (authInfo.Credential.Username == "Gekctek" && authInfo.Credential.Password == "Welc0me!")
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString())
};
var identity = new ClaimsIdentity(claims, "Basic");
var principal = new ClaimsPrincipal(identity);
var properties = new AuthenticationProperties();
return Task.FromResult(new AuthenticationTicket(principal, properties, "Basic"));
}
return Task.FromResult<AuthenticationTicket>(null);
};
});
app.Map("/RpcApi", rpcApp =>
{
rpcApp.UseJsonRpc(builder =>
{
builder.RegisterTypeRoute<RpcMath>();
builder.RegisterTypeRoute<RpcString>("Strings");
builder.RegisterTypeRoute<RpcCommands>("Commands");
builder.RegisterTypeRoute<RpcMath>("Math");
});
});
}
示例10: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment hostEnv, ILoggerFactory loggerFactory)
{
//loggerFactory.MinimumLevel = LogLevel.Information;
// root min level: you have to set this the most detailed, because if not ASPlog will not pass it to the NLogExtension
//loggerFactory.MinimumLevel = Microsoft.Extensions.Logging.LogLevel.Debug;
// A. ASP.NET5 LogLevels can come from appsettings.json or set here programmatically. But Configuration.GetSection("") returns text from the file,
// and not the file itself, so ConsoleLogger is not able to reload config when appsettings.json file is changed.
// For that you need a FileSystem watcher manually, which is not OK on Linux systems I guess or not on DNXCore
// Therefore logging level cannot be changed by modifying that file (at least, not without extra FileSystemWatcher programming)
// B. On the other hand Nlog is based on DNX, not DNXCore, and implements FileSystemWatcher properly, and I tested it and
// when the app.nlog file is changed by Notepad nLog under Asp.NET notices the LogLevelChange.
loggerFactory.AddConsole(Configuration.GetSection("LoggingToConsole"));
//loggerFactory.AddConsole(LogLevel.Debug); // write to the Console (if available) window as Colorful multiline (in Kestrel??) . MinLevel can be specified. by default it is LogLevel.Information
loggerFactory.AddDebug(Microsoft.Extensions.Logging.LogLevel.Debug); // write to the Debug output window (in VS). MinLevel can be specified. by default it is LogLevel.Information
// set nLog here if NLog works properly
loggerFactory.AddProvider(new SQLabAspLoggerProvider());
// using https://github.com/aspnet/Security/blob/59fc691f4152e6d5017176c0b700ee9834640481/samples/SocialSample/Startup.cs
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
//AuthenticationScheme = "MyCookieMiddlewareInstance", // by default "Cookies"
//CookieName = ".SQ.AspNetCore.Cookies", // ".AspNetCore.Cookies"
AutomaticAuthenticate = true, // default is true
AutomaticChallenge = true,
LoginPath = new PathString("/login"), // if CloudFront string is in the Request Header, then the "/login" should be "https:www.snifferquant.net/login". However, this is a global setting, not URL request dependent.
//So, whatever, leave the temporary solution that Google authentication is HTTP, but after that we move back to HTTPS
SlidingExpiration = true, // default is true
ExpireTimeSpan = TimeSpan.FromDays(30), // default is 14 days
//CookieHttpOnly = false, // default: true.The default is true, which means the cookie will only be passed to only HTTP requests and is not made available to JS script on the page
//CookieSecure = CookieSecureOption.Never // default: CookieSecurePolicy.SameAsRequest;
});
if (!String.IsNullOrEmpty(Utils.Configuration["GoogleClientId"]) && !String.IsNullOrEmpty(Utils.Configuration["GoogleClientSecret"]))
{
//mStartupLogger.LogInformation("A_G_CId and A_G_CSe from Config has been found. Initializing GoogelAuthentication.");
app.UseGoogleAuthentication(new GoogleOptions
{
//AuthenticationScheme = "MyCookieMiddlewareInstance", // by default "Google"
SignInScheme = "Cookies", // this will connect to the AuthenticationScheme field of the cookieAuth
ClientId = Utils.Configuration["GoogleClientId"],
ClientSecret = Utils.Configuration["GoogleClientSecret"],
//RemoteAuthenticationTimeout = TimeSpan.FromDays(30), // Workaround1 for ExpireTimeSpan is not honored bug. Yes. This fixes that cookie.ExpireTimeSpan is not honored. Having the same issue. Effectively RemoteAuthenticationOptions.RemoteAuthenticationTimeout is used for cookie ticket lifetime.
// SaveTokens: Defines whether access and refresh tokens should be stored in the Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties
// after a successful authorization. This property is set to false by default to
// reduce the size of the final authentication cookie.
//SaveTokens = true,
Events = new OAuthEvents()
{
OnRemoteFailure = ctx =>
{
ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message));
ctx.HandleResponse();
return Task.FromResult(0);
},
// https://github.com/aspnet/Security/issues/855
// Having the same issue. Effectively RemoteAuthenticationOptions.RemoteAuthenticationTimeout is used for cookie ticket lifetime.
// You can workaround this in IRemoteAuthenticationEvents.OnTicketReceived callback, this works for me...
OnTicketReceived = ctx =>
{
// Workaround2 for ExpireTimeSpan is not honored bug. Reset ticket authentication properties
ctx.Properties = new AuthenticationProperties() { IsPersistent=true };
return Task.FromResult(0);
}
}
});
}
else
{
Console.WriteLine("A_G_CId and A_G_CSe from Config has NOT been found. Cannot initialize GoogelAuthentication.");
Utils.Logger.Warn("A_G_CId and A_G_CSe from Config has NOT been found. Cannot initialize GoogelAuthentication.");
}
app.UseStaticFiles(); // without it, the Server will not return static files like favicon.ico or other htm files
ConfigureStaticFiles(app, hostEnv, loggerFactory);
// Choose an authentication type
app.Map("/login", signoutApp =>
{
signoutApp.Run(async context =>
{
//string cloudFrontSuccessfulAuthUri = String.Empty; // "https"
//foreach (var header in context.Request.Headers)
//{
// Console.WriteLine($"{header.Key} : {header.Value}");
// if (header.Key == "CloudFront-Forwarded-Proto")
// {
// //cloudFrontForwardedProto = header.Value + "://"; //"https"
// cloudFrontSuccessfulAuthUri = "https://" + context.Request.Host.ToString(); // if "CloudFront-Forwarded-Proto" has been found temporary overwrite to HTTPS, even if it comes from HTTP. So we redirect HTTP back to HTTPS
// Console.WriteLine($"cloudFrontForwardedProto = '{header.Value}'");
// }
//}
var authenticationScheme = context.Request.Query["authscheme"]; // "Google" or "Facebook"
//.........这里部分代码省略.........
示例11: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//loggerFactory.MinimumLevel = LogLevel.Information;
// root min level: you have to set this the most detailed, because if not ASPlog will not pass it to the NLogExtension
loggerFactory.MinimumLevel = Microsoft.Extensions.Logging.LogLevel.Debug;
// A. ASP.NET5 LogLevels can come from appsettings.json or set here programmatically. But Configuration.GetSection("") returns text from the file,
// and not the file itself, so ConsoleLogger is not able to reload config when appsettings.json file is changed.
// For that you need a FileSystem watcher manually, which is not OK on Linux systems I guess or not on DNXCore
// Therefore logging level cannot be changed by modifying that file (at least, not without extra FileSystemWatcher programming)
// B. On the other hand Nlog is based on DNX, not DNXCore, and implements FileSystemWatcher properly, and I tested it and
// when the app.nlog file is changed by Notepad nLog under Asp.NET notices the LogLevelChange.
loggerFactory.AddConsole(Configuration.GetSection("LoggingToConsole"));
//loggerFactory.AddConsole(LogLevel.Debug); // write to the Console (if available) window as Colorful multiline (in Kestrel??) . MinLevel can be specified. by default it is LogLevel.Information
loggerFactory.AddDebug(Microsoft.Extensions.Logging.LogLevel.Debug); // write to the Debug output window (in VS). MinLevel can be specified. by default it is LogLevel.Information
#if !DNXCORE50
#if NlogInternalLoggingNeeded
// nLog searches these config files in GetCandidateFileNames() (version nLog 3.1), later renamed to GetCandidateConfigFileNames()
// NLog.config from application directory, "C:\\Users\\gyantal\\.dnx\\runtimes\\dnx-clr-win-x86.1.0.0-rc1-update1\\bin\\NLog.config"
string standardCandidate = Path.Combine(NLog.LogFactory.CurrentAppDomain.BaseDirectory, "NLog.config"); // myExeFolder/Nlog.config
// current config file with (EXE) .config renamed to .nlog, "g:\\work\\Archi-data\\GitHubRepos\\SQHealthMonitor\\src\\SQHealthMonitor\\app.nlog"
string appDotNlog = Path.ChangeExtension(NLog.LogFactory.CurrentAppDomain.ConfigurationFile, ".nlog"); //myExeFolder/MyExe
// get path to NLog.dll.nlog only if the assembly is not in the GAC, "C:\\Users\\gyantal\\.dnx\\packages\\NLog\\4.2.2\\lib\\net45\\NLog.dll.nlog"
string dllDotNlog = typeof(NLog.LogFactory).Assembly.Location + ".nlog";
NLog.Common.InternalLogger.LogLevel = NLog.LogLevel.Trace; // this sets up from the default highLevel Info to detailed Trace; in order for Internal NLog logging to be Verbose
NLog.Common.InternalLogger.LogToConsole = true;
NLog.Common.InternalLogger.LogFile = @"g:\temp\nlogKestrel_InternalLogger.log";
#endif
//NLog.ILogger tempNlogLogger = LogManager.GetCurrentClassLogger(); //https://github.com/nlog/NLog/wiki/Configuration-file
//SetNLogTableStorageConnectionString();
//// when nlog.config is rewritten while the exe is running, AzureTableStorageConnectionString is lost
//LogManager.ConfigurationReloaded += (sender, args) => { SetNLogTableStorageConnectionString(); };
//tempNlogLogger.Info("This Logger created by LogManager() works properly under ASP.NET5. Writes proper AzuteStorageTable");
//During Webserver runtime(Debugging in VS), file modification of app.nlog should not be done in VS2015, because
//VS has a trick that it doesn't change file's Time under Debug, and so NLog.dll will not notice that this config file has been changed.
//So, change this config file in NotePad.exe or TotalCommander, etc.
NLog.LogFactory nlogLogFactory = new global::NLog.LogFactory();
SetNLogTableStorageConnectionStringAndEmailSmtp(nlogLogFactory);
// when nlog.config is rewritten while the exe is running, AzureTableStorageConnectionString is lost
nlogLogFactory.ConfigurationReloaded += (sender, args) => { SetNLogTableStorageConnectionStringAndEmailSmtp(nlogLogFactory); };
loggerFactory.AddProvider(new NLogLoggerProvider(nlogLogFactory));
//nlogLogFactory.ConfigurationReloaded += (sender, args) => { SetNLogTableStorageConnectionString(); };
//loggerFactory.AddNLog(nlogLogFactory);
//loggerFactory.AddEventLog(); // probably Windows Eventlogs, implemented in Microsoft.Extensions.Logging.EventLog
System.AppDomain.CurrentDomain.DomainUnload += (sender, args) => {
Thread.Sleep(1);
nlogLogFactory.Flush();
LogManager.Flush();
};
System.AppDomain.CurrentDomain.ProcessExit += (sender, args) => {
//Checked: when I shutdown the Webserver, by typing Ctrl-C, saying Initiate Webserver shutdown, this is called second after calling Dispose() of all IDispose objects
Thread.Sleep(1);
nlogLogFactory.Flush();
LogManager.Flush();
};
System.AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
Thread.Sleep(1);
nlogLogFactory.Flush();
LogManager.Flush();
};
#endif
mStartupLogger = loggerFactory.CreateLogger(typeof(Program).FullName);
mStartupLogger.LogInformation("****START: Loggers are initialized in Startup.Configure()"); // high Level UserInfo
#if !DNXCORE50
////Logger = LogManager.GetCurrentClassLogger(); //https://github.com/nlog/NLog/wiki/Configuration-file
//SetNLogTableStorageConnectionString();
//// when nlog.config is rewritten while the exe is running, AzureTableStorageConnectionString is lost
//LogManager.ConfigurationReloaded += (sender, args) => { SetNLogTableStorageConnectionString(); };
//var mStartupLogger2 = loggerFactory.CreateLogger(typeof(Program).FullName + "2");
//mStartupLogger2.LogInformation("****creating mStartupLogger2 after setting ConnString."); // high Level UserInfo
#endif
//gStartupLogger.LogDebug("This is LogDebug() log info"); // most detailed, Trace in nLog
//gStartupLogger.LogVerbose("This is LogVerbose() log info"); // normal-detailed, Debug in nLog
//gStartupLogger.LogInformation("This is LogInformation() log info"); // high Level UserInfo
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler(); // : it is needed to resolve the Windows identity corresponding to the token flowed by IIS.
if (env.IsDevelopment())
{
//app.UseDeveloperExceptionPage();
}
//Utils.InitSt();
// Agy: I think this ASP5 solution is token based too. Just stores token in Cookies, which is perfect for a Browser based app like AngularJS
//A. Conclusion: Storage user-token(not proper bearer token, but token) in cookies is good (in an AngularJS webApp, cookie storage is ideal.)
//https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/
//Conclusion: "Stormpath recommends that you store your JWT in cookies for web applications, because of the additional security they provide, and the simplicity of protecting against CSRF with modern web frameworks. HTML5 Web Storage (from here to Authentication Header) is vulnerable to XS"
//.........这里部分代码省略.........
示例12: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddProvider(new SqlLoggerProvider());
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
.CreateScope())
{
serviceScope.ServiceProvider.GetService<UnicornStoreContext>().Database.Migrate();
serviceScope.ServiceProvider.GetService<ApplicationDbContext>().Database.Migrate();
}
app.EnsureSampleData();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
app.EnsureRolesCreated();
// See comments in config.json for info on enabling Facebook auth
var facebookId = Configuration["Auth:Facebook:AppId"];
var facebookSecret = Configuration["Auth:Facebook:AppSecret"];
if (!string.IsNullOrWhiteSpace(facebookId) && !string.IsNullOrWhiteSpace(facebookSecret))
{
app.UseFacebookAuthentication(options =>
{
options.AppId = facebookId;
options.AppSecret = facebookSecret;
});
}
// See comments in config.json for info on enabling Google auth
var googleId = Configuration["Auth:Google:ClientId"];
var googleSecret = Configuration["Auth:Google:ClientSecret"];
if (!string.IsNullOrWhiteSpace(googleId) && !string.IsNullOrWhiteSpace(googleSecret))
{
app.UseGoogleAuthentication(options =>
{
options.ClientId = googleId;
options.ClientSecret = googleSecret;
});
}
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例13: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddProvider(new SyncLogProvider());
// loggerFactory.AddConsole();
// loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseExceptionHandler("/Home/Error");
// app.UseMiddleware<SyncExceptionMiddleware>();
}
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add and configure the options for authentication middleware to the request pipeline.
// You can add options for middleware as shown below.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
//app.UseFacebookAuthentication(options =>
//{
// options.AppId = Configuration["Authentication:Facebook:AppId"];
// options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
//});
//app.UseGoogleAuthentication(options =>
//{
// options.ClientId = Configuration["Authentication:Google:ClientId"];
// options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
//});
//app.UseMicrosoftAccountAuthentication(options =>
//{
// options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"];
// options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"];
//});
//app.UseTwitterAuthentication(options =>
//{
// options.ConsumerKey = Configuration["Authentication:Twitter:ConsumerKey"];
// options.ConsumerSecret = Configuration["Authentication:Twitter:ConsumerSecret"];
//});
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute("default", "{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?}");
});
app.UseSignalR();
}
示例14: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, DbSeeder dbSeeder, RedisMessagesHub messagesHub)
{
loggerFactory.AddProvider(new Log4NetProvider());
// For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
.CreateScope())
{
serviceScope.ServiceProvider.GetService<ApplicationDbContext>().Database.Migrate();
}
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
await dbSeeder.EnsureSeedData();
app.UseFacebookAuthentication(options =>
{
options.AppId = Configuration["Authentication:Facebook:AppId"];
options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
options.Events = new OAuthEvents
{
OnRemoteError = ctx =>
{
ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
ctx.HandleResponse();
return Task.FromResult(0);
}
};
});
app.ConfigureForumsSockets(messagesHub, "/sockets");
//app.UseOAuthAuthentication(new OAuthOptions
// {
// AuthenticationScheme = "Google-AccessToken",
// DisplayName = "Google-AccessToken(oauth{1})",
// ClientId = Configuration["google:clientid"],
// ClientSecret = Configuration["google:clientsecret"],
// CallbackPath = new PathString("/signin-google-token"),
// AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint,
// TokenEndpoint = GoogleDefaults.TokenEndpoint,
// Scope = {"openid", "profile", "email"},
// SaveTokensAsClaims = true
// });
//// See config.json
//// https://console.developers.google.com/project
//app.UseGoogleAuthentication(new GoogleOptions
// {
// ClientId = Configuration["google:clientid"],
// ClientSecret = Configuration["google:clientsecret"],
// DisplayName = "Second google",
// Events = new OAuthEvents()
// {
// OnRemoteError = ctx =>
// {
// ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
// ctx.HandleResponse();
// return Task.FromResult(0);
// }
// }
// });
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
//app.UseCompression();
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
//routes.MapRoute("DefaultApiPost", "Api/{controller}/{action}");
});
}