How to enable basic authentication before the processing the request in asp.mvc? (Description inside)
<>This question already has an answer here:
- ASP.NET MVC - HTTP Authentication Prompt 4 answers
Answers
here give u demo which is define about authenticate of client
here is about controller code
[HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { var userInfo = new UserInfo { UserName = model.UserName, Password = model.Password, //AppType = "Web" }; var service = new ATWMSService(); if(service.ValidateUser(userInfo)) { Session["UserId"] = service.GetUserId(userInfo.UserName); FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } return Redirect("~/"); } ModelState.AddModelError("","The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form return View(model); }