Asp.net mvc 4 MVC自定义授权在live server上运行一段时间后自动停止
我已经创建了asp.NETMVC网站,并创建了自定义身份验证和授权功能。此功能工作一段时间,但在一定时间后停止工作。有人能帮忙吗 没有错误,用户只需访问限制区域即可 我的自定义代码:Asp.net mvc 4 MVC自定义授权在live server上运行一段时间后自动停止,asp.net-mvc-4,authentication,authorization,asp.net-identity,Asp.net Mvc 4,Authentication,Authorization,Asp.net Identity,我已经创建了asp.NETMVC网站,并创建了自定义身份验证和授权功能。此功能工作一段时间,但在一定时间后停止工作。有人能帮忙吗 没有错误,用户只需访问限制区域即可 我的自定义代码: [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public class CustomAuthrizationPayment : AuthorizeAttribute {
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public class CustomAuthrizationPayment : AuthorizeAttribute
{
bool authorize = false;
bool IsLoggedIn = false;
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
string currentUserId = HttpContext.Current.User.Identity.Name;
if (!string.IsNullOrEmpty(currentUserId))
{
using (IACLBEntities context = new IACLBEntities())
{
var userStatus = context.AspNetUsers.FirstOrDefault(r => r.Email == currentUserId).IsActive;
if (userStatus != null)
{
authorize = (bool)userStatus;
IsLoggedIn = true;
}
else
{
authorize = false;
}
}
}
return authorize;
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
if (IsLoggedIn == false)//----- Return To Login page
{
filterContext.Result = new HttpUnauthorizedResult();
}
else
{
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary
{
{ "action", "Index" },
{ "controller", "Payment" },
{"area","" }
});
}
}
}
我如何申请控制器:
[CustomAuthrizationPayment()]
public class CorporateRefrencesController : Controller
{
您也可以附加HTTP请求吗?在哪里可以找到?