asp.net-core

The antiforgery token could not be decrypted

Deadly 提交于 2021-02-19 01:11:58
问题 I have an identity server asp net core project deployed in Azure, i also have two asp net 5 mvc client using my identity server as SSO, and continuously i am getting(save in logs) an exception The antiforgery token could not be decrypted . 回答1: We had similar issue today, We were able to resolve by persisting data protection keys to file system . services.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo(@"\\UNC-PATH")); 回答2: We had the same error message Antiforgery token

Disable being able to edit code while debugging

我与影子孤独终老i 提交于 2021-02-18 23:35:34
问题 Recently when I've been debugging my application, I've been able to write code into C# files when the application isn't in the broken state. I've tried totally disabling the "Edit and Continue" setting in the visual studio options but that doesn't seem to be working. What I'm expecting to happen is when I'm debugging and I type into a C# file, I want that popup that says "Changes are not allowed while the application is running" prompting me to put a breakpoint in my code to apply changes

ASP.NET Core 3.1 web application throws error 500.30 when run on IIS Express, but not when using dotnet watch run

爷,独闯天下 提交于 2021-02-18 22:55:07
问题 When running my application from Visual Studio 2019 on IIS Express the web page gives error 500.30 and in the output it says, Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll However, when running it in a terminal using dotnet watch run the page runs without errors and displays correctly. I've tried running the debugger and the error is always thrown on this line, CreateHostBuilder(args).Build().Run(); after my ConfigureSerives Method below completes // This

Get session service using IServiceProvider

♀尐吖头ヾ 提交于 2021-02-18 22:42:50
问题 I need to access session variable in ConfigureService method in ASP.NET Core 1.0 using IServiceProvider. I have a service that is initialized with delegate/lambda expression that can return value from any place. In this context this lambda expression argument should return value from session once called. Here is example code: public void ConfigureServices(IServiceCollection services) { services.AddTransient<IMyService>(serviceProvider => { return new MyService(() => { var session =

Get session service using IServiceProvider

旧街凉风 提交于 2021-02-18 22:42:35
问题 I need to access session variable in ConfigureService method in ASP.NET Core 1.0 using IServiceProvider. I have a service that is initialized with delegate/lambda expression that can return value from any place. In this context this lambda expression argument should return value from session once called. Here is example code: public void ConfigureServices(IServiceCollection services) { services.AddTransient<IMyService>(serviceProvider => { return new MyService(() => { var session =

Why is ClaimTypes.NameIdentifier not mapping to 'sub'?

冷暖自知 提交于 2021-02-18 22:07:25
问题 Using ASP.NET Core 2.2 and Identity Server 4 I have the following controller: [HttpGet("posts"), Authorize] public async Task<IActionResult> GetPosts() { var authenticated = this.User.Identity.IsAuthenticated; var claims = this.User.Identities.FirstOrDefault().Claims; var id = this.User.FindFirstValue(ClaimTypes.NameIdentifier); } I get all the claims but id is null ... I checked all values in claims and I have a 'sub' claim with value 1. Why is ClaimTypes.NameIdentifier not mapping to 'sub'?

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

孤街醉人 提交于 2021-02-18 20:13:43
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources:

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

梦想的初衷 提交于 2021-02-18 20:11:57
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources:

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

会有一股神秘感。 提交于 2021-02-18 20:05:52
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources:

Asp.net Core Middleware that cancel a request if taking to long

送分小仙女□ 提交于 2021-02-18 18:57:15
问题 I need a middleware to cancel a request if my api is taking more than x amount of time. All my api calls are asynch and cancellable: public async Task<IActionResult> Get(CancellationToken token) { } ... public async Task InvokeAsync(HttpContext context) { //.... int customDurationMilis = 1000; //1second cancellTimer = new Timer(CancellRequestCallBack, context, customDurationMilis, Timeout.Infinite); //... await _next(context); } private void CancellRequestCallBack(HttpContext context) { //log