-
Represents an attribute that specifies which HTTP verbs an action method will respond to.
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index() { return View(); }
[AcceptVerbs("get", "post")]
public ActionResult Index() { return View(); }
-
Represents the base class for filter attributes.
public class PermissionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
base.OnResultExecuting(filterContext);
}
}
-
Represents an attribute that is used to influence the selection of an action method.
public class RequestSourceFilterAttribute : ActionMethodSelectorAttribute
{
public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
{
throw new NotImplementedException();
}
}
-
Represents an attribute that is used for the name of an action.
[ActionName("Substitute")]
public ActionResult Index() { return View(); }
-
Represents an attribute that affects the selection of an action method.
public class RequestSourceFilterAttribute : ActionNameSelectorAttribute
{
public override bool IsValidName(ControllerContext controllerContext, string actionName, System.Reflection.MethodInfo methodInfo)
{
throw new NotImplementedException();
}
}
-
Allows a request to include HTML markup during model binding by skipping request validation for the property. (It is strongly recommended that your application explicitly check all models where you disable request validation in order to prevent script exploits.)
[AllowHtml]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to set the timeout value, in milliseconds, for an asynchronous method.
[AsyncTimeout(1000000)] // In milliseconds.
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to restrict access by callers to an action method.
[Authorize(Users = "Betty, Johnny", Roles = "Admin, Super User")]
public ActionResult Index() { return View(); }
public class ApplicationAuthorizaeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return base.AuthorizeCore(httpContext);
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
base.HandleUnauthorizedRequest(filterContext);
}
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
}
protected override HttpValidationStatus OnCacheAuthorization(HttpContextBase httpContext)
{
return base.OnCacheAuthorization(httpContext);
}
}
-
Represents an attribute that is used to indicate that an action method should be called only as a child action.
[ChildActionOnly]
public ActionResult Index() { return View(); }
@{Html.RenderAction("Index");}
-
Represents the base class for action and result filter attributes.
public class BaseFileter : FilterAttribute
{
public override bool IsDefaultAttribute()
{
return base.IsDefaultAttribute();
}
public override bool Match(object obj)
{
return base.Match(obj);
}
}
-
Represents an attribute that is used to handle an exception that is thrown by an action method.
[HandleError(Master = "Site", View = "Error", ExceptionType = typeof(NullReferenceException))]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to restrict an action method so that the method handles only HTTP DELETE requests.
[HttpDelete]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to restrict an action method so that the method handles only HTTP GET requests.
[HttpGet]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to restrict an action method so that the method handles only HTTP POST requests.
[HttpPost]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to restrict an action method so that the method handles only HTTP PUT requests.
[HttpPut]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to indicate that a controller method is not an action method.
[NonAction] // Prevent called from url
public void InnerCall() { Response.Write("Hello InnerCall"); Response.End(); }
-
Represents an attribute that is used to mark an action method whose output will be cached.
[OutputCache(Duration = 60, VaryByParam = "page")]
public ActionResult Index() { return View(); }
-
Represents an attribute that forces an unsecured HTTP request to be re-sent over HTTPS.
[RequireHttps]
public ActionResult Index() { return View(); }
-
Specifies the session state of the controller.
[SessionState(System.Web.SessionState.SessionStateBehavior.Required)]
public ActionResult Index() { return View(); }
-
Represents an attribute that is used to mark action methods whose input must be validated.
[ValidateInput(false)]
public ActionResult Index() { return View(); }