C# Class Decision.Common.Filters.RedirectToCanonicalUrlAttribute

Inheritance: System.Web.Mvc.FilterAttribute, IAuthorizationFilter
Show file Open project: rabbal/Decision

Public Methods

Method Description
OnAuthorization ( System.Web.Mvc.AuthorizationContext filterContext ) : void

Determines whether the HTTP request contains a non-canonical URL using TryGetCanonicalUrl, if it doesn't calls the HandleNonCanonicalRequest method.

RedirectToCanonicalUrlAttribute ( bool appendTrailingSlash, bool lowercaseUrls ) : System

Initializes a new instance of the RedirectToCanonicalUrlAttribute class.

Protected Methods

Method Description
HandleNonCanonicalRequest ( System.Web.Mvc.AuthorizationContext filterContext, string canonicalUrl ) : void

Handles HTTP requests for URL's that are not canonical. Performs a 301 Permanent Redirect to the canonical URL.

HasNoTrailingSlashAttribute ( System.Web.Mvc.AuthorizationContext filterContext ) : bool

Determines whether the specified action or its controller has the NoTrailingSlashAttribute attribute specified.

TryGetCanonicalUrl ( System.Web.Mvc.AuthorizationContext filterContext, string &canonicalUrl ) : bool

Determines whether the specified URl is canonical and if it is not, outputs the canonical URL.

Method Details

HandleNonCanonicalRequest() protected method

Handles HTTP requests for URL's that are not canonical. Performs a 301 Permanent Redirect to the canonical URL.
protected HandleNonCanonicalRequest ( System.Web.Mvc.AuthorizationContext filterContext, string canonicalUrl ) : void
filterContext System.Web.Mvc.AuthorizationContext An object that encapsulates information that is required in order to use the /// attribute.
canonicalUrl string The canonical URL.
return void

HasNoTrailingSlashAttribute() protected method

Determines whether the specified action or its controller has the NoTrailingSlashAttribute attribute specified.
protected HasNoTrailingSlashAttribute ( System.Web.Mvc.AuthorizationContext filterContext ) : bool
filterContext System.Web.Mvc.AuthorizationContext The filter context.
return bool

OnAuthorization() public method

Determines whether the HTTP request contains a non-canonical URL using TryGetCanonicalUrl, if it doesn't calls the HandleNonCanonicalRequest method.
The parameter is null.
public OnAuthorization ( System.Web.Mvc.AuthorizationContext filterContext ) : void
filterContext System.Web.Mvc.AuthorizationContext An object that encapsulates information that is required in order to use the /// attribute.
return void

RedirectToCanonicalUrlAttribute() public method

Initializes a new instance of the RedirectToCanonicalUrlAttribute class.
public RedirectToCanonicalUrlAttribute ( bool appendTrailingSlash, bool lowercaseUrls ) : System
appendTrailingSlash bool If set to true append trailing slashes, otherwise strip trailing /// slashes.
lowercaseUrls bool If set to true lower-case all URL's.
return System

TryGetCanonicalUrl() protected method

Determines whether the specified URl is canonical and if it is not, outputs the canonical URL.
protected TryGetCanonicalUrl ( System.Web.Mvc.AuthorizationContext filterContext, string &canonicalUrl ) : bool
filterContext System.Web.Mvc.AuthorizationContext An object that encapsulates information that is required in order to use the /// attribute.
canonicalUrl string The canonical URL.
return bool