13.1: Test Login
In this section, we begin Postman testing with the login page.
Test the URL
You may want to work on another branch
Make sure ElevenNote.Web is still the startup project
Run the app and log off if you're logged in
Copy the URL localhost:XXXXX
XXXXX stands for whatever number your port is in the address bar
Open Postman
Close the window that comes up
Paste the URL, set the request to POST and press Send
Test the Login URL
Login in to your ElevenNote app
Back in Postman, add /Account/Login to the URL and make sure the request is set to POST
Click on the Body tab, select x-www-form-urlencoded, and add the three key/value pairs as shown below:
You should get a 500 Internal Server error. Error codes are explained in section 19.
Looking at the response, it seems we need a token to log in.
Stop the app
Test the [ValidateAntiForgeryToken]
[ValidateAntiForgeryToken]
Open ElevenNote.Web -> Controllers -> AccountController
Comment out
[ValidateAntiForgeryToken]
above the login methodThis is temporary, we'll change it back
[HttpPost] [AllowAnonymous] //[ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) }
Run the app and login
Go to Postman and hit Send again with the same request
You should get 200 OK
DO THIS IMMEDIATELY: Stop the app
Un-comment
[ValidateAntiForgeryToken]
, restart the app, and login.Retest in Postman, you should get the 500 error again.
Stop the app
Next, we'll add SSL for release builds.
Last updated