Created
July 17, 2022 06:10
-
-
Save srafay/479dff91f56d2e43d2da174a03c76679 to your computer and use it in GitHub Desktop.
Trying to create Layout Renderer for accessing NavigationManager Uri (Blazor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. First Configure NLog for Blazor application. | |
2. Once NLog is configured, add the following files for creating a new layouy renderer (for Navigation Manager) | |
- AspNetNavigationManagerLayoutRenderer.cs (in Layout Renderers) | |
- NLogNavigationManagerMiddlewareOptions.cs | |
- NLogNavigationManagerMiddleware.cs | |
3. In Program.cs or Startup.cs (depending on your .NET Core version), use the middleware app.UseMiddleware<NLogNavigationManagerMiddleware>(); | |
4. In NLog.config file, you can access the navigation-manager-uri property as ${event-properties:item=navigation-manager-uri}. | |
layout="${event-properties:item=navigation-manager-uri} ${message}" | |
OR | |
layout="${when:when='${event-properties:item=navigation-manager-uri}'!='':Inner=${event-properties:item=navigation-manager-uri} }${message}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment