Last post Jun 10, 2019 07:07 AM by Xing Zou
Jun 08, 2019 06:20 AM|mrsadin|LINK
Jun 08, 2019 01:53 PM|mgebhard|LINK
I am using ASP.Net Core MVC and Identity Core for authentication in my project, it works fine but i want to create mobile app and other ui from some apis that i have in my main project.
For example i want to createobile app to create new Post, now i need to authenticate user, as you know in mobile and apis i dont hace cookies and i ahould use token base authentication.
I read many articles about jwt but all of them are using web api as base project but as i said my main project is mvc.
I am so confused!!!! When i set [Authorized] attribute on api action it works fine when i pass token in request but other authentications that i have used for areas fail!!!!
Can you help me to get the point?
MVC is a UI framework. It is not clear why a mobile application needs to invoke an MVC action. If you have business logic in MVC controllers and you wish to share the logic then you should refactor the code into a service. Use constructor injection to
inject the service into the controllers that need the logic.
Can you explain the design intent?
Keep in mind, that it is very difficult to answer questions without source code that reproduces the issue.
Jun 09, 2019 09:04 AM|mrsadin|LINK
Jun 09, 2019 01:18 PM|mgebhard|LINK
Jun 10, 2019 07:07 AM|Xing Zou|LINK
When we use the Authorize attribute, it actually binds to the first authentication system by default.The [Authorize] attribute could specify the authentication scheme or schemes to use regardless
of whether a default is configured:
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class ValuesController : Controller
In the preceding code, only the handler with the "Bearer" scheme runs. Any cookie-based identities are ignored.
For details on how to use identity and Jwt in asp.net core MVC ,refer to: