Skip to content
Loading
action method not found after post the login form in iisthis is controller "LoginController"
 
  1. namespace DeltaSoftLIS.Controllers  
  2. {  
  3. [Area("Reception")]  
  4. public class LoginController : Controller  
  5. {  
  6.     private readonly ApplicationDbContext _db;  
  7.   
  8.     public LoginController(ApplicationDbContext context)  
  9.     {  
  10.         _db = context;  
  11.     }  
  12.     public IActionResult Index()  
  13.     {  
  14.         return View();  
  15.     }  
  16.   
  17.   
  18.     [HttpPost]  
  19.     //[Route("/Reception/Login/Index/{username?}/{password}")]  
  20.     public IActionResult Index(string ? username, string ? password)  
  21.     {  
  22.   
  23.         var userId = _db.logins.Where(p=>p.UserName==username && p.Password==password && p.ExpiryDate> DateTime.Now).Select(p=>p.Id).FirstOrDefault();  
  24.         if (userId>0)  
  25.         {  
  26.             HttpContext.Session.SetString("username", username);  
  27.             return Redirect("~/Reception/Home/Index");  
  28.         }  
  29.         else  
  30.         {  
  31.             ViewBag.error = "Invalid Login..!";  
  32.             return View("Index");  
  33.         }  
  34.     }  
  35.   
  36.     [HttpGet]  
  37.     public IActionResult Logout()  
  38.     {  
  39.         HttpContext.Session.Remove("username");  
  40.         return RedirectToAction("Index");  
  41.     }  
  42.   }  
  43.  }  
Kindly help me to resolve this issue. I am stuck here 

2 Replies

Know the answer? Post it — somebody with the same question will find it here.