❔ where exactly should i put authorization

so i read a few posts on where to put authorization and most of the people agree on putting it in the service rather than in controller. but in asp.net there's this [Authorize] attribute which if you try to put somewhere else rather than in the controller it just won't work - it doesn't block any endpoint and throws no errors (at least with no authentication scheme specified) whereas when i put it in the controller it works as expected - blocks the endpoint and throws expected error - in this case 500 internal server error, no authentication scheme specified. so my question is should i just use authorization in the controller or there's a way of implementing it in the service? and which way is better?
What about implementing the authorization logic in a service and injecting this service into your controller that has the [Authorize] attribute on a function?
so what you mean by that is just putting all the authorization-related code outside the controller and leaving controller functions with just [Authorize] attribute?
UUUnknown User2/3/2023
12 Messages Not Public
Sign In & Join Server To View
this is the super annoying and shitty way to do this it works dont get me wrong its just annoying I hate asp authz, how are all the solution so dogshit
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ C# WPF playing background musicHello, I have WPF app for game launcher/updater. I wanted to add background music, so I added this cC# wpf mvvm Datagrid filter using LINQSo here I have a MVVM form. the Form contains a Datagrid which is connected to the Databank. I also ❔ Is it worth to create lazy dictionary in this case?I have following class: so as you see Add function add to the dictionary class TreeNode, it looks li❔ Going to use a listbox with a switch for something in the morning, need help with format for bothI would like to set two variables with a listbox using a switch and one variable with a second listb✅ What's your view on tool like Sonarqube?Should I learn from the code smells it captures?✅ Autodesk Maya HelpAnyone in here know Autodesk Maya really well? My mesh tool isn't letting my polygon primitives mesh❔ circular primesso this program is meant to find how many circular primes there are below 1 million (should be 55), ❔ WPF Cannot find child when it's thereHi! I am working on my own RoundedCorners attachedproperty however I have stumbled upon a problem Pr❔ HttpClient exiting program during GetStringAsync() and GetAsync()I'm sending a GET to an API, but when debugging, as soon as you step off the last line, it cuts out ✅ Homework Helphttps://i.gyazo.com/f23d758d46581bcfb84f88d4178cd484.png What should I return from the FillArray() ❔ force a ushort value?if i type for example var num = 25L; i am forcing a long value (int64) how can i force a ushort in ❔ Doing post method with entity frameworki'm making a simple API to practice with entity framework but when i try to make a post to a table w❔ I can't reference a class library please helpI can't reference a class library i t says compilation error❔ ASP.NET REMOTE DEVELOPMENTHey does anyone know if I would need nginx for remote development on a ubuntu server from my windowException/NULL/Error handling advice.DeserializeAsync clearly returns a nullable generic object. From the picture we can clearly see that❔ ASP.NET Core web app vs ASP.net web application(.NET Framework)Hi, Ive been working with c# for a while now and would like to make a webapp but I dont know where t✅ IGNORE PEOPLEmy place for testing commands❔ Game Hubhi, how can i program my own game hub, like battle.net where i can download and start my own games ?❔ ✅ beginner class and propertiesi am doing basic program abt class and getting information from input but on the weight section whe❔ Best practice to retrieve MySQL columnsHello wonderful people! Can you please help me understanding what would be the best practice to ret