.net-core-3.0

Get Current User in a Blazor component

喜夏-厌秋 提交于 2020-08-02 19:12:34
问题 I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with Context.User.Identity.Name , but that doesn't seem to work in a Blazor component. I've tried injecting HttpContext into the component but the Context is null at runtime. As a bonus, I will eventually want to incorporate this into Startup.cs so I only need to get the username once and can leverage a

Get Current User in a Blazor component

余生颓废 提交于 2020-08-02 19:01:29
问题 I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with Context.User.Identity.Name , but that doesn't seem to work in a Blazor component. I've tried injecting HttpContext into the component but the Context is null at runtime. As a bonus, I will eventually want to incorporate this into Startup.cs so I only need to get the username once and can leverage a

The difference between abstract classes and interfaces in C# 8 release? [closed]

℡╲_俬逩灬. 提交于 2020-07-31 03:27:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 months ago . Improve this question So in C# 8 interfaces will be able to have actual implementations of methods. At that point, what will be the difference between abstract classes and interfaces and why would I ever use abstract class anymore?What would be the advantage of this change

Serialize/Deserialize a class hierarchy with .NET Core System.Text.Json

大兔子大兔子 提交于 2020-07-30 02:56:31
问题 I have a simple class hierarchy that I want to serialize using System.Text.Json. There are 3 classes. The base is Shape . Inherited ones are Box and Circle . I have a plan to use these classes as a tagged union on my frontend app so I just introduced a discriminator property Tag . I wrote a type convertor that supports serialization/deserialization of this hierarchy. What I'm trying to understand - is this a best approach to implement such functionality or not. Indeed the output result of

Swagger and .Net Core 3 integration

一曲冷凌霜 提交于 2020-07-09 08:56:12
问题 I'm documenting my web api using swagger. However when I run my Project, it throws an error "Method not found: 'Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware...". I only followed the tutorials from youtube. Not sure what is the cause of error. My project is .Net Core 3. internal class SwaggerConfiguration { public static void Configure(IServiceCollection services) { services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info() { Title = "Sample Portal API", Version = "1.0.0.0" });

How to handle Appsettings for .net core 3.1 self contained single file publish

老子叫甜甜 提交于 2020-06-15 16:10:09
问题 I have a new .NET Core 3.1 worker class that is hosted as a Windows Service. I am using the default appsettings.json and appsettings.environment.json that were created by the template. The appsettings is loaded from the hostContext during ConfigureServices .ConfigureServices((hostContext, services) => { services.AddHostedService<Worker>(); services.Configure<BasicSettings>(hostContext.Configuration.GetSection("AppSettings")); }); I want to be able to edit the appsettings after it is deployed

How to handle Appsettings for .net core 3.1 self contained single file publish

筅森魡賤 提交于 2020-06-15 16:07:50
问题 I have a new .NET Core 3.1 worker class that is hosted as a Windows Service. I am using the default appsettings.json and appsettings.environment.json that were created by the template. The appsettings is loaded from the hostContext during ConfigureServices .ConfigureServices((hostContext, services) => { services.AddHostedService<Worker>(); services.Configure<BasicSettings>(hostContext.Configuration.GetSection("AppSettings")); }); I want to be able to edit the appsettings after it is deployed

Installer for .net core 3 wpf/winforms (non MSIX)?

↘锁芯ラ 提交于 2020-06-09 04:08:29
问题 So, we finished a few wpf conversions to .net core, and now we have a need to ship one to an external client as an installer. Previously we used ClickOnce, but that has been deprecated in .net core and will not be ported according to MS, with them recommending MSIX. However, as we understood from docs, even though we'll sideload a WPF application it will still run in a sandbox with a virtualized file system. And that is a no go for us, it has obviously been designed with UWP+Marketplace

Change visibility of nav item in blazor menu

点点圈 提交于 2020-05-29 10:17:18
问题 I'm using Blazor with .NET Core 3.0. I want to show a login in my menu, when the user isn't logged in yet. When he is logged in, then the login nav item should be hidden. How can I do this? EDIT: I changed the OnInitializedAsync method by using async Task, but this is not the problem. For the first load, it works correctly. But then i go to the login page, log me in and Navigate to the home page via NavigationManager, the menu will not be "refreshed". How can I solve this? Following code is

NuGet: Necessary to reference implicit dependencies?

杀马特。学长 韩版系。学妹 提交于 2020-05-23 13:32:12
问题 I recently upgraded from ASP.NET Core 2.2. to 3.0. With the changes regarding their meta packages, I'm now in a state where everything works, but some pretty important packages are not explicitly referenced. Everything works because, they're implicitly referenced. For example: You can see that I'm explicitly referencing Microsoft.EntityFrameworkCore.SqlServer, however I am NOT referencing Microsoft.EntityFrameworkCore explicitly. It's still pulled in because it's an indirect reference it