BestQA.Web/Controllers/AccountController.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using BestQA.Web.Models;
using Microsoft.AspNet.Identity;
using Microsoft.Owin.Security;
namespace BestQA.Web.Controllers
{
[Authorize]
public class AccountController : Controller
{
//
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
//直接生成登陆用户,在实际的项目中采用数据库形式
var user = new ApplicationUser() { UserName = model.UserName };
await SignInAsync(user, model.RememberMe);
return RedirectToLocal(returnUrl);
}
return View(model);
}
//
// GET: /Account/Register
[AllowAnonymous]
public ActionResult Register()
{
return View();
}
//
// GET: /Account/Manage
public ActionResult Manage(ManageMessageId? message)
{
return View();
}
//
// POST: /Account/LogOff
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
