C
C#•3w ago
Metalkon

Auth Controller Structure & Error Handling

I am trying to replace the old login/register controllers in my asp.net web api portfolio project because most of it consists of "if" statements with very little separation of concerns. I'm asking claude/chatgpt for some ideas for me to learn from to make a professional looking controller, and it's showing me this ExecuteAuthFlow method in a base controller (top) for error handling, and an AuthService for things such as user validation in the login controller (bottom) that inherits from the base controller. I'm wondering if this is the right direction for my portfolio project with how an auth system should be made?
No description
5 Replies
Angius
Angius•3w ago
That seems way overcomplicated Middleware should be handling exceptions
Metalkon
MetalkonOP•3w ago
I'm just at situation where I don't know what I don't know, so just trying to figure out how I should build my controllers for error handling and structure. 😄
Angius
Angius•3w ago
You should not, when it comes to exceptions Let them bubble up and be caught by the middleware Handle them there, if needed If not, just return ProblemDetails from that middleware
Metalkon
MetalkonOP•3w ago
I have never worked on middleware as far as I am aware, I don't know how I would do this with middlewhere, got any advice or know where I can figure it out?

Did you find this page helpful?