Я пытаюсь создать пользовательский атрибут AuthorizeAttribute, поэтому в моем основном проекте (библиотеке классов) у меня есть этот код:
using System;
using System.Web;
using System.Web.Mvc;
using IVC.Core.Web;
using System.Linq;
namespace IVC.Core.Attributes
{
public class TimeShareAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
if(!httpContext.Request.IsAuthenticated)
return false;
var rolesProvider = System.Web.Security.Roles.Providers["TimeShareRoleProvider"];
string[] roles = rolesProvider.GetRolesForUser(httpContext.User.Identity.Name);
if(roles.Contains(Website.Roles.RegisteredClient, StringComparer.OrdinalIgnoreCase))
{
return true;
}
return false;
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.Result = new RedirectResult("/TimeShare/Account/LogOn");
base.HandleUnauthorizedRequest(filterContext);
}
}
}
Когда я пытаюсь построить вещь, я получаю эту ошибку: Ошибка 2 'IVC.Core.Attributes.TimeShareAuthorizeAttribute.AuthorizeCore(System.Web.HttpContextBase)': не найдено подходящего метода для переопределения...
Я что-то упустил? Я искал все, но каждый сайт, который я могу найти, просто говорит мне, что я делаю именно то, что я здесь сделал. Я использую mvc2 btw.
- Отредактировано для добавления: если я переведу класс в проект mvc в том же решении, ошибки компилятора не будут.