C# Class FiftyOne.Foundation.Mobile.Redirection.RedirectModule

Class responsible for handling redirection based on predefined rules.
Inheritance: IHttpModule
ファイルを表示 Open project: 51Degrees/dotNET-Device-Detection Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Sends any queued data and records the module being disposed if debug enabled.

Init ( System.Web.HttpApplication application ) : void

Initiliases the HttpMobile registering this modules interest in all new requests and handler mappings.

IsFirstTime ( HttpContext context ) : bool

Determines if this is the first request received from the device assuming first request only is set in the configuration.

IsFirstTime ( HttpContext context, bool cookies ) : bool

Determines if this is the first request received from the device.

IsMobilePage ( HttpContext context ) : bool

Returns true if the current handler relates to a mobile web page.

Private Methods

Method Description
GetExpiryDateTime ( ) : long

Returns a long value representing the expiry date time to be used for the current request.

GetIsFirstTime ( HttpContext context, bool cookies ) : bool

Determines if this is the first request received from the device. Should only be called once pre request.

GetLocation ( HttpContext context ) : Location

Returns the location object to be used for the request if any.

GetLocationName ( HttpContext context ) : string

Gets the name of the currently active location if one is being used. Only used for debugging.

GetLocationUrl ( HttpContext context ) : string

Evaluates the location that should be used when redirecting the requesting context. If the locations collection does not provide a location then the mobile home page url will be used only if the device is a mobile.

GetOriginalUrl ( HttpContext context ) : string

Returns the Url stored in the context when the request first began before other modules may have changed it. If not available returns the Url using the current request value.

IsInArray ( string value, string array ) : bool

Checks the value is contained in the array.

IsMobileRegexPage ( HttpContext context ) : bool

Checks to see if the regular expression provided matches either the relative executing path or the Url of the request.

IsMobileType ( Type type ) : bool

Checks the type to see if it's one that matches a mobile web page.

IsPage ( HttpContext context ) : bool

Returns true if the request relates to a handler that relates to web page.

IsPageType ( Type type ) : bool

Checks the array of page types to determine if the type past into the method is in the array. Also checks basetypes where available.

IsRestrictedPageForRedirect ( HttpContext context ) : bool

Checks the page being requested to determine if it is eligable for redirection. The mobile home page and the forms authentication login page are restricted from redirection. If the response is already being redirected it should be ignored.

OnBeginRequest ( object sender, EventArgs e ) : void

Record the original requesting URL.

OnPostAcquireRequestState ( object sender, EventArgs e ) : void

If the handler assigned to the request isn't a mobile one and the browser that is accessing the page is a wireless device then redirect the browser to the mobile home page for the site. The redirect is done through the resposne to ensure a fresh request is made to the server.

RecordFirstTime ( HttpContext context, bool cookies ) : void

Records in the session (if present) and in a cookie the requesting devices first request. This ensures subsequent calls to IsFirstTime return the correct value.

RecordNewDevice ( HttpContext context ) : void

Record the new device if we're as certain as we can be that it is not one we've processed already.

RegisterEventHandlersInit ( System.Web.HttpApplication application ) : void

Registers the event handlers if they've not done so already.

SetResponseCookie ( HttpContext context, System.Web.HttpCookie alreadyAccessed ) : void

Sets the response cookie expiry time.

SetSession ( HttpContext context ) : void

Sets the session key to the expiry time for the current device.

ShouldRequestRedirect ( HttpContext context ) : bool

Returns true if the request should be redirected.

StaticFieldInit ( System.Web.HttpApplication application ) : void

Initialises the static fields.

WipeResponseCookie ( HttpContext context, System.Web.HttpCookie alreadyAccessed ) : void

Removes the cookie from the browser by setting it's expiry time to a date in the past.

Method Details

Dispose() public method

Sends any queued data and records the module being disposed if debug enabled.
public Dispose ( ) : void
return void

Init() public method

Initiliases the HttpMobile registering this modules interest in all new requests and handler mappings.
public Init ( System.Web.HttpApplication application ) : void
application System.Web.HttpApplication /// object for the web application.
return void

IsFirstTime() public static method

Determines if this is the first request received from the device assuming first request only is set in the configuration.
public static IsFirstTime ( HttpContext context ) : bool
context System.Web.HttpContext Context of the request.
return bool

IsFirstTime() public static method

Determines if this is the first request received from the device.
public static IsFirstTime ( HttpContext context, bool cookies ) : bool
context System.Web.HttpContext Context of the request.
cookies bool True if the first time routine is allowed to use response cookies.
return bool

IsMobilePage() public static method

Returns true if the current handler relates to a mobile web page.
public static IsMobilePage ( HttpContext context ) : bool
context System.Web.HttpContext The context associated with the Http request.
return bool