You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$10
For Premium members:
In this article you will learn about how to implement authentication and authorization in ASP.NET Web API through UI.
Before proceeding to this article, please go through my previous articles:
In this article I am going to use the UI for explaining the token based individual authentication and authorization in ASP.NET Web API. Get the details about how to create an individual authentication template in ASP.NET Web API here.
In my previous article I have explained token based authentication using POST MAN tool, now we are going to create a UI to do those operations
Let us start with Registration:
1. Create an HTML page in the project which we created in part-3 and name it Register.html
/api/account/Register is the API used for registration
Register.html
Result in Browser
HTTP POST request Params
Record successfully stored in the table
Login.html
Enter the Email and the password and hit login button,
It's time to access the authorize action methods in the application, For example, consider the following authorize action method which is in ValuesController:
Since we are using the session storage the token will be stored till the page session expires, if we have opened the application in separate tab/window in browser then our token will be cleared.
Using Local Storage:
By using local storage the token is stored locally in the browser and it will persist till the token is removed from the local browser memory.
Logout:
HTML Code:
Authorization based on user
For example, consider the following authorize action method which is in values controller:
ASP.NET GridView Control Pocket Guide