Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Configure(IApplicationBuilder app)
- {
- app.UseStaticFiles();
- app.UseCookiePolicy();
- app.UseAuthentication();
- app.Use(async (ctxt, next) =>
- {
- if(ctxt.User == null)
- {
- // Not logged in, so nothing to do.
- await next();
- }
- else
- {
- // Set a scoped value in the NLog context, then call the next
- // middleware.
- var userName = ctxt.User.Identity.Name;
- using (MappedDiagnosticsLogicalContext.SetScoped("userName", userName))
- {
- await next();
- }
- }
- });
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement