Change NuGet package folders used by Visual Studio

UPD 2024: standalone nuget commands replaced with dotnet nuget CLI. The information provided is relevant for VS2022 and .NET 8. Cache locations Solution-local packages folders are no longer used by .NET Core and Visual Studio. The command to list user-specific folders is: dotnet nuget locals all –list And its typical output (I’ve replaced absolute paths … Read more

Host.CreateDefaultBuilder vs Host.CreateApplicationBuilder in .NET Platform Extension 7

It is documented a bit here and here. The general idea was to move away from calbacks and move to linear code for configuring everything Code samples from the link… Web var builder = WebApplication.CreateBuilder(); builder.Logging.AddConsole(); builder.Services.AddOptions<MyOptions>().BindConfiguration(“MyConfig”); builder.Services.AddHostedService<MyWorker>(); var app = builder.Build(); app.MapGet(“/”, () => “Hello World”); app.Run(); Non-Web var builder = Host.CreateApplicationBuilder(); builder.Logging.AddConsole(); builder.Services.AddOptions<MyOptions>().BindConfiguration(“MyConfig”); … Read more

How do I actually create a .NET Core project in Visual Studio?

.NET Core templates are available in Visual Studio 2017. When installing VS2017, you have to pick the “.NET Core cross-platform development” workload. Once you do, you’ll have access to the templates: Click File – New Project. Expand Visual C# – .NET Core on the left side. Pick one of the templates. If you’re on Visual … Read more

Entity Framework Core migration – connection string

All the examples I’ve seen involve either hard-coding the connection string or putting it in my ASP.NET Core application’s settings files. If you aren’t using ASP.NET Core, or maybe, I don’t know, don’t want to have your local environment’s database details committed to source control, you can try using a temporary environment variable. First, implement … Read more

C# WASM without Blazor

Yes it’s absolutely possible. Blazor does not have a monopoly on C#/WASM and it’s far from clear that it’s going to wind up being the best long term option (and a lot of evidence it’s not). I recommend starting with the Uno WASM Bootstrap. https://github.com/unoplatform/Uno.Wasm.Bootstrap 2022-06-30 Edit – More evidence Blazor is not the only … Read more

Dotnet core 2.0 authentication multiple schemas identity cookies and jwt

Asp.Net Core 2.0 definitely support multiple authentication schemes. Rather than a hacking with authenticate middleware, you can try to specify the schema in Authorize attribute: [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] I gave a try and it worked fine. Assuming you have added both Identity and JWT as below: services.AddIdentity<ApplicationUser, ApplicationRole>() services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) Since AddIdentity() already set cookie authentication … Read more

AutoValidateAntiForgeryToken vs. ValidateAntiForgeryToken

From AutoValidateAntiforgeryTokenAttribute documentation: An attribute that causes validation of antiforgery tokens for all unsafe HTTP methods. An antiforgery token is required for HTTP methods other than GET, HEAD, OPTIONS, and TRACE. It can be applied at as a global filter to trigger validation of antiforgery tokens by default for an application. AutoValidateAntiforgeryTokenAttribute allows to apply … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)