|
asp .net mvc authorize attribute does not store persist post data
Here is the solution . The solution is to use a session variable . The below solution worked for me.
Leedhar_HKI _db = new Leedhar_HKI();
//
// GET: /ApnaLawyer/
[HttpGet]
public ActionResult Index()
{
if (Session["LawyerConsultation"] != null)
{
LawyerConsultation oLawyerConsultation = (LawyerConsultation)Session["LawyerConsultation"];
oLawyerConsultation.State = "New";
oLawyerConsultation.UserID = User.Identity.Name;
oLawyerConsultation.EntTime = DateTime.Now;
_db.LawyerConsultationa.Add(oLawyerConsultation);
_db.SaveChanges();
_db.SaveChanges();
Session.Remove("DoctorConsultation");
return View("ThankYou");
}
return View();
}
[HttpPost]
public ActionResult Index(LawyerConsultation oLawyerConsultation)
{
if (User.Identity.IsAuthenticated)
{
oLawyerConsultation.State = "New";
oLawyerConsultation.UserID = User.Identity.Name;
oLawyerConsultation.EntTime = DateTime.Now;
_db.LawyerConsultationa.Add(oLawyerConsultation);
_db.SaveChanges();
return View("ThankYou");
}
else
{
Session["LawyerConsultation"] = oLawyerConsultation;
return RedirectToAction("LogOn", "Account", new { returnUrl = "/ApnaLawyer/Index" });
}
}
http://stackoverflow.com/questions/924514/authorize-attribute-does-not-preserve-post-data
http://stackoverflow.com/questions/10096700/asp-net-mvc-preserve-post-data-after-authorize-attribute-login-redirect
|