cyan_live
cyan_live
CC#
Created by cyan_live on 12/25/2022 in #help
❔ JWT token claims not working anymore after deploying application to Azure web app.
The code that is working inside a controller locally but not working when deployed on azure Attempt 1#
var obj = _httpContextAccessor.HttpContext;
var currentAccountId = _httpContextAccessor.HttpContext
.User.Claims
.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;


var account = _accountService.GetAccountById(int.Parse(currentAccountId));
var obj = _httpContextAccessor.HttpContext;
var currentAccountId = _httpContextAccessor.HttpContext
.User.Claims
.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;


var account = _accountService.GetAccountById(int.Parse(currentAccountId));
Attempt 2
var currentAccountId = int.Parse(User.FindFirst(ClaimTypes.Name).Value);
var currentAccountId = int.Parse(User.FindFirst(ClaimTypes.Name).Value);
On Azure I get a null System.ArgumentNullException error on the above line of code
2 replies
CC#
Created by cyan_live on 9/9/2022 in #help
Solution to mixing SQL queries with entity framework entities
Hi guys, So I have a code base that uses manually written SqlConnection queries AND entity framework entities to read and write to the database. Now I want to fix the duplicate code and make everything more organized. I think putting both the sql connection code and entity framework behind repositories in a data project. So the repositories can be reused instead of copy pasting SqlConnection code with adjustments which is the case now. The question is: what is the most effective way to organize the SqlConnection code and entity framework code so it can be reused and avoids duplication.
37 replies
CC#
Created by cyan_live on 8/22/2022 in #help
namespace missing imports after copying class [Answered]
Hi guys, I am struggling with a problem for a few weeks. So I have a ASP.NET Website project (Not web application) inside I have a folder called App_Code with many classes without namespaces inside. They magically reference each other without issues. Now I wish to copy a class to a folder outside of App_Code so for example New_Folder. I choose refactor and move the class to the New_Folder. What happens now is that every class inside App_Code can't find the class that I moved into New_Folder. Only way I am able to reference the class inside New_Folder is by giving it a namespace and importing that in the classes inside App_Code. What's the issue? Well I have 100 classes inside App_Code and after copying it to New_Folder I have thousands of missing references. Is there a way to copy classes out of app_code and keep the reference to the other classes in App_Code?
13 replies
CC#
Created by cyan_live on 8/17/2022 in #help
ASP.NET Website project without namespaces. Converting to ASP.NET Web application.
Hi guys, I have a legacy ASP.NET Website project which I want to convert to ASP.NET Website application. So I can actually reference it from outside and unit test. The problem is now. I have followed the guide and copied the code over to a new project. Everything went well. Just one big problem. Classes don't see each other references anymore. I get hundreds of errors. So I tried using resharper to create namespaces for every class. This went kinda well and now every class has a namespace App_Code. Now, for some reason using import App_Code doesn't work but I am able to directly reference classes by using var example = new App_Code.ExampleClass; I have hundreds of lines I need to edit to directly reference the classes. Anyone have any tip or advice how I can make my life less of a hell?
1 replies