- Copy
MusicSalesApp/appsettings.Development.json.sampletoMusicSalesApp/appsettings.Development.json - Run the application:
dotnet run --project MusicSalesApp - Open browser to
https://localhost:7173(or the port shown in console)
- Navigate to the home page
- Verify: NavMenu shows "Login" link (not "Logout")
- Verify: No authentication cookies in browser dev tools under Application > Cookies
- Click "Login" link
- Enter credentials:
- Username:
admin@app.com - Password:
Password_123
- Username:
- Click "Login" button
- Expected Result:
- Page reloads and navigates to home page
- NavMenu now shows "Logout" link (not "Login")
- Authentication cookie appears in browser dev tools:
- Name:
.AspNetCore.Identity.Application - Path:
/ - HttpOnly: Yes
- Secure: Yes (on HTTPS)
- Name:
- User is authenticated
- If logged in, click "Logout" first
- Click "Login" link
- Enter credentials:
- Username:
user@app.com - Password:
Password_123
- Username:
- Click "Login" button
- Expected Result: Same as Test 1
- If logged in, click "Logout" first
- Click "Login" link
- Enter invalid credentials:
- Username:
admin@app.com - Password:
WrongPassword
- Username:
- Click "Login" button
- Expected Result:
- Error message displayed: "Invalid username or password."
- No page reload
- NavMenu still shows "Login"
- No authentication cookie set
- Login with valid credentials
- Verify: NavMenu shows "Logout"
- Click "Logout" link
- Expected Result:
- Page reloads
- NavMenu now shows "Login"
- Authentication cookie is removed from browser
The authentication cookie should be named .AspNetCore.Identity.Application (not .AspNetCore.Cookies or any other name).
Authentication now uses ASP.NET Core Identity's SignInManager directly on the server side:
- No JavaScript interop required
- All authentication happens server-side
- Proper session management via Identity cookies
- Works correctly during server-side prerendering
- Verify database connection in appsettings.Development.json
- Ensure migrations have been applied (automatic on startup)
- Check application logs for authentication errors
- Verify user exists in database with correct credentials
- Try logging in with default users (admin@app.com or user@app.com / Password_123)
- Check application logs for any errors during logout
- Verify the page reloads to /login after clicking Logout
- Check that the
.AspNetCore.Identity.Applicationcookie is removed from browser - If issues persist, try clearing all browser cookies and cache