HomeController
TheHomeController provides basic application navigation and session management functionality.
Source
Controllers/HomeController.cs
Methods
Index
Returns the main home page view.IActionResult - The home page view
Privacy
Returns the privacy policy page view.IActionResult - The privacy view
Error
Handles application errors and displays the error page with diagnostic information.[ResponseCache]- Disables caching for error pages
IActionResult - Error view with ErrorViewModel containing request ID
Usage:
LogIn (GET)
Displays the login form.IActionResult - The login view
LogIn (POST)
Processes user login and stores the username in session.The username to store in session
IActionResult - The login view with success message
Session Storage:
LogOut
Clears the user session and redirects to home page.Username parameter (not used in implementation)
IActionResult - Redirect to Index action
Session Removal:
Session Configuration
For session management to work, ensure session middleware is configured inProgram.cs:
Program.cs
Related
Session Management Example
See complete session implementation
ErrorViewModel
Error model documentation