RedirectOnHost Class Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

This class Redirects the user to a URL depending on hostname in request header.
Inheritance Hierarchy

SystemObject
  ContentStudio.SiteCodeBase
    ContentStudio.Site.ActiveScriptingActiveScriptingBase
      ContentStudio.Site.ActiveScripting.MiscRedirectOnHost

Namespace: ContentStudio.Site.ActiveScripting.Misc
Assembly: CS_SiteLib (in CS_SiteLib.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public sealed class RedirectOnHost : ActiveScriptingBase

The RedirectOnHost type exposes the following members.

Constructors

  NameDescription
Public methodRedirectOnHost
Constructs a new instance of the RedirectOnHost class.
Top
Properties

  NameDescription
Public propertyBackwardsComponentCompatibilityMode
Sets or gets a value that indicates whether the code runs in backwards compatibility component mode. The default value is false.
(Inherited from ActiveScriptingBase.)
Public propertyComponentName
Gets the name of the component
(Overrides ActiveScriptingBaseComponentName.)
Public propertyConformance
Gets a value which specifies which type of code a component can generate.
(Overrides ActiveScriptingBaseConformance.)
Public propertyElementType
Gets a value which specifies the type of outer element the component generates.
(Overrides ActiveScriptingBaseElementType.)
Public propertyEncoding
Sets or gets the encoding the component uses. The default encoding is the UTF8 encoding without byte order mark.
(Inherited from ActiveScriptingBase.)
Public propertyEvaluationMethod
Sets or gets a value that specifies how the host name in the request header should match the critera supplied in the Hostname property. The default value is CriteriaEqual.
Public propertyHostname
Sets or gets a value that specifies the hostname to match on. The default value is "www.".
Public propertyInverseCriteria
Sets or gets a value that specifies whether to perform the redirect if criteria doesn't match or not. The default value is false.
Public propertyRedirectURL
Sets or gets a value that specifies an URL to redirect to if criteria is met, or if InverseCriteria is true no met. The default value is "http://".
Top
Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodInvoke
This method invokes the component.
Public methodToString (Inherited from Object.)
Top
Remarks

The RedirectOnHost class acts as the underlying engine for the Redirect on host Content Studio component. Create an instance of this object, set the properties that does not have their default values you expect and call the invoke method. The generates inline code thus you must wrap it into a block element in order for the resulting code to validate. The code generated is fully HTML/XHTML strict compatible.
Remarks

This class can throw exceptions thus your code should be wrapped within try/catch statements in order to avoid the entire page to crash.
Examples

The following code demonstrates how to use the RedirectOnHost class.
to redirect visitors to different parts of a web page based on the URL entered by the user. Typically you place this code on the top of a start page that acts as a switch between different parts of the website. Depending on the url the caller entered she will be redirected to different parts (ex. localized versions) of the web site. In this case the site has three domain pointing at the same site http://mycompany.se for international, http://mycompany.dk for Danish and http://mycompany.com for international vistors. In order to work this Content Studio site must be configured to use Multi homing both in Content Studio and in the web server.

C#
//Create the RedirectOnHost object and set the EvaluationMethod to CriteriaEqual
RedirectOnHost bb = new RedirectOnHost();
bb.EvaluationMethod = ContentStudio.Site.ActiveScripting.Misc.RedirectOnHost.EvaluationMethods.CriteriaEqual;
//Redirect Swedish customers to the Swedish start page
bb.Hostname = "mycompany.se";
bb.RedirectURL = "http://mycompany.se/default.aspx?di=2348";
bb.Invoke();
//Redirect Danish customers to the Danish start page
bb.Hostname = "mycompany.dk";
bb.RedirectURL = "http://mycompany.dk/default.aspx?di=3478";
bb.Invoke();
//The rest will be redirected to the International start page
Response.Redirect("http://mycompany.com/default.aspx?di=8888");
Visual Basic
'Create the RedirectOnHost object and set the EvaluationMethod to CriteriaEqual
Dim bb = New RedirectOnHost()
bb.EvaluationMethod = ContentStudio.Site.ActiveScripting.Misc.RedirectOnHost.EvaluationMethods.CriteriaEqual
'Redirect Swedish customers to the Swedish start page
bb.Hostname = "mycompany.se"
bb.RedirectURL = "http://mycompany.se/default.aspx?di=2348"
bb.Invoke();
'Redirect Danish customers to the Danish start page
bb.Hostname = "mycompany.dk"
bb.RedirectURL = "http://mycompany.dk/default.aspx?di=3478"
bb.Invoke()
'The rest will be redirected to the International start page
Response.Redirect("http://mycompany.com/default.aspx?di=8888")
See Also

Reference