MvcApplication2/Controllers/AuthenticationController.cs
(完整代码) 1KBusing MvcApplication2.Bussiness;
using MvcApplication2.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
namespace MvcApplication2.Controllers
{
public class AuthenticationController : Controller
{
//
// GET: /Authentication/
public ActionResult Login()
{
return View("Login");
}
public ActionResult DoLogin(UserDetails u)
{
EmployeeBusinessLayer embuss=new EmployeeBusinessLayer();
if (ModelState.IsValid&&u.UserName=="admin"&&u.PassWord=="51aspx")
{
UserStatus us = embuss.GetUserValidity(u);
bool IsAdmin = true;
if (us == UserStatus.AuthentucatedUser)
{
IsAdmin = false;
}
Session["IsAdmin"] = IsAdmin;
FormsAuthentication.SetAuthCookie(u.UserName, false);
return RedirectToAction("Index", "Employee");
}
else
{
ModelState.AddModelError("CredentialError", "无效的用户名和密码");
return View("Login");
}
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Login");
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。