(自定义用户类型)只是一些调整
测试控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Authorise.Controllers
{
public class TestController : Controller
{
// GET: /Default1/
[CustomAuthorize(UserType = "Admin")]
public ActionResult Index()
{
return View();
}
}
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
public string UserType { get; set; }
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
if (UserType == "Admin")
{
return true;
}
else
{
return false;
}
}
}
}
测试视图
@{
ViewBag.Title = "Test";
}
<h2>Test</h2>
帐户控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Authorise.Controllers
{
public class AccountController : Controller
{
//
// GET: /Account/
public ActionResult Index()
{
return View();
}
public ActionResult LogOn()
{
return View();
}
}
}
帐户登录视图
@{
ViewBag.Title = "LogOn";
}
登录