Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using DotNetOpenAuth.AspNet;
using Microsoft.Web.WebPages.OAuth;
using WebMatrix.WebData;
using Mvc4WithAuthentication.Filters;
using Mvc4WithAuthentication.Models;
namespace Mvc4WithAuthentication.Controllers
public class AccountController : Controller
/* skipped quite a few actions here */
public ActionResult Login(LoginModel model, string returnUrl)
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
//store the user's identity in the session
Session["UserName"] = model.UserName;
return RedirectToLocal(returnUrl);
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
/* skipped quite a few actions here */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment