aspnetcore/test/WebSites/AntiForgeryWebSite/Controllers/AccountController.cs

31 lines
953 B
C#

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
namespace AntiForgeryWebSite
{
// This controller is reachable via traditional routing.
public class AccountController : Controller
{
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login(string returnUrl = null)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
// Send to register which gets another html antiforgery token.
return RedirectToAction("Index", "Home");
}
}
}