SecuriteController.cs 764 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Web.Security;
  7. namespace AppliWebANA.Controllers {
  8. public class SecuriteController : Controller {
  9. [HttpGet]
  10. public ActionResult Index() {
  11. return View();
  12. }
  13. [HttpPost]
  14. public ActionResult Index(string nom, string mdp, string returnUrl) {
  15. if( Request.Form.AllKeys.Contains( "creer" ) ) {
  16. MembershipCreateStatus status;
  17. Membership.CreateUser( nom, mdp, "ezeze@zeze.com", "q", "r", true, out status );
  18. return View();
  19. }
  20. else {
  21. if( Membership.ValidateUser( nom, mdp ) ) {
  22. FormsAuthentication.SetAuthCookie( nom, false );
  23. return Redirect( returnUrl );
  24. }
  25. else
  26. return View();
  27. }
  28. }
  29. }
  30. }