Jens Chr. I. Thomsen
Jens Chr. I. Thomsen

Reputation: 41

Authentication for a blazor server controller

I have a Blazor server application where I have a controller where I access some methods. My Blazor project uses Microsoft Azure AD to log in the user. On my pages I have something like this to authenticate users. @attribute [Authorize(Policy = "App.Users")] and that work just fine.

But in my controller file I have the same [Authorize(Policy = "App.Users")], but this is not working. When I call my method I can see that the response i some kind of login. I guess i tries to get me to login.

On the other hand if I enter the api call directly in my browser address bar it works fine.

I am using IHttpClientFactory to call my api controller method.

Can anyone please help me or guide me in the right direction.

Upvotes: 0

Views: 252

Answers (1)

Jens Chr. I. Thomsen
Jens Chr. I. Thomsen

Reputation: 41

I did find an answer. I just put my delete method in a class file with the [Authorize(Policy = "App.Users")] and it works now.

Upvotes: 0

Related Questions