Prevent redirect to /Account/Login in asp.net core 2.2

The behaviour you experience is linked to the fact that you use ASP.NET Identity. When you call services.AddIdentity, behind the scenes a cookie-based authentication scheme is registered and set as the default challenge scheme, as you can see in the code here on GitHub. Even though you registered a cookie authentication scheme yourself and set … Read more

Mock IOptionsMonitor

You are calling the constructor of the OptionsMonitor<TOptions> class incorrectly. In this case I would have just mocked the IOptionsMonitor<AuthenticationSettings> interface For example using Moq AuthenticationSettings au = new AuthenticationSettings() { … }; var monitor = Mock.Of<IOptionsMonitor<AuthenticationSettings>>(_ => _.CurrentValue == au); ActiveDirectoryLogic _SUT = new ActiveDirectoryLogic(monitor);

Disable verbose logging of symbol loading in vscode debug console

These logs are managed by VS Code. You can disable them in the launch.json file in the .vscode directory. You can add the following node inside any of the elements in the configurations node to disable module load messages for that configuration: “logging”: { “moduleLoad”: false } There are more options available such as exceptions … Read more

Asp.Net core Tempdata and redirecttoaction not working

TempData uses Session, which itself uses IDistributedCache. IDistributedCache doesn’t have the capability to accept objects or to serialize objects. As a result, you need to do this yourself, i.e.: TempData[“PopupMessages”] = JsonConvert.SerializeObject(_popupMessages); Then, of course, after redirecting, you’ll need to deserialize it back into the object you need: TempData[“PopupMessages”] = JsonConvert.DeserializeObject<List<PopupMessage>>(TempData[“PopupMessages”].ToString());

Why is ClaimTypes.NameIdentifier not mapping to ‘sub’?

To not let Microsoft Identity to override claim names you have to use JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); just before the app.UseAuthentication() in the API startup. Use direct “sub” claim instead of ClaimThypes.NameIdentifier e.g. var id = this.User.FindFirstValue(“sub”); For further reference please see detailed discussion on it: https://github.com/IdentityServer/IdentityServer4/issues/2968#issuecomment-510996164

What are differences between Portable and win-x64 when deploying?

Edit – Short Answer If you choose portable, every time the app starts up it will need to go through JIT compilation on the parts of the application that actually execute. If your application is large, the performance can be impacted. If you choose x64, the application will not slow down from compilation, because that … Read more

Asp.net core HttpsRedirectionMiddleware Failed to determine the https port for redirect

See the documentation for various ways of configuring a non-default HTTPS port. Which approach suits your scenario best depends on how your application is set up and hosted. You could for example add a setting: public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseSetting(“https_port”, “5001”) .UseStartup<Startup>();

How to fix obsolete ILoggerFactory methods?

I had the same issue today. Remove your logging configuration from Startup.cs and go to your Program.cs file and add something like: var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection(“Logging”)); logging.AddConsole(); logging.AddDebug(); }) .Build(); This used the ‘builder’ because the variable ‘logging’ is an IloggingBuilder (whereas your code is … Read more

How to fix error “ANCM In-Process Handler Load Failure”?

I had the same issue in .Net core 2.2. When I replace web.config: <handlers> <add name=”aspNetCore” path=”*” verb=”*” modules=”AspNetCoreModuleV2″ resourceType=”Unspecified” /> </handlers> to <handlers> <add name=”aspNetCore” path=”*” verb=”*” modules=”AspNetCoreModule” resourceType=”Unspecified” /> </handlers> then it works fine. Note: The same solution also works for .Net core 2.2 and other upper versions as well.

How to create a LoggerFactory with a ConsoleLoggerProvider?

In Microsoft.Extensions.Logging 3.0+, you can use the much simpler LoggerFactory.Create: var loggerFactory = LoggerFactory.Create(builder => { builder.AddFilter(“Microsoft”, LogLevel.Warning) .AddFilter(“System”, LogLevel.Warning) .AddFilter(“SampleApp.Program”, LogLevel.Debug) .AddConsole(); }); For Microsoft.Extensions.Logging version 2.2+, you can build an ILoggerFactory without using obsolete methods via Microsoft’s dependency injection framework. It’s a little less verbose than the 2.1 version where everything is constructed … Read more

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