I did some quick Googling and didn't come up with any way to do this, so I apologize if this question is a duplicate.
I have a class like:
using System.Web;
using System.Web.Mvc;
namespace Authorization
{
public class AuthorizeAttribute : ActionFilterAttibute
{
public string Address { get; set; }
public override void OnActionExecuting(ActionExecutingContext context)
{
if (HttpContext.Current.Request.UserHostAddress != Address)
context.Result = new HttpStatusCodeResult(403);
base.OnActionExecuting(context);
}
}
}
The problem is that whenever I add this attribute to other classes in my project, it can be defined two ways. The first way is basically like calling the default constructor for the attribute; no data is passed in. The second way allows Address
to be specified.
I have a feeling that I can't remove the first option, because it's probably specified somehow through the parent class of the one I created. But is it possible to only have the second option? This would be ideal.