The Switch.To environment can be set up either automatically or manually. See section "Setting up a Switch.To Environment Automatically using DeployASPNET.bat" to configure the Switch.To Environment automatically and see section "Setting up a Switch.To Environment Manually" for the manual configuration.
Prerequisites to Setup the Switch.To Environment
The prerequisites to setup the Switch.To environment either automatically or manually are as follows:
For a segment, the Alternate Name under Persistence and Application Name under Component Enabler User Interface must be same. Otherwise, each application comes up and runs in its own unique virtual directory. However, it is assumed that if the Alternate Name is blank, then the name of the Segment and the Application Name must be the same.
The bundle name for all applications that are being switched between must be same.
The deployed Segment or System Name is case sensitive, therefore, ensure to use the System Name accordingly when accessed from the browser.
Note: Ensure that each ASP.NET application, which is to be prepared for Switching environment, should be working fine when accessed using the CompileASPNET.bat file provided in the next point using Option 2.
Before compiling each ASP.NET application by using the CompileASPNET.bat file located in views folder (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\ views), change the path of devenv.exe file in the CompileASPNET.bat file using Option 2 based on the qualified version of Visual Studio for AB Suite release. For editing the CompileASPNET.bat file, perform the following steps:
In Option 1, comment the line "csc /t:library /out:bin\Sample1_aspnet.dll /recurse:*.cs /r:C:\NGEN_CE\bin\CEWindowsAPI.dll /r:C:\NGEN_CE\bin\CEWindowsAPIPool.dll /r:bin\CEWebFormRenderer.dll /r:bin\UniMenu.dll /r:bin\UniCombo.dll" by inserting "REM" in front of it.
In Option 2, uncomment the line ""C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /out C:\Temp\CEASPNETWebForm_BuildLog.txt /build release CEASPNETWebForm.sln" by removing "REM".
Setting up a Switch.To Environment Automatically using DeployASPNET.bat
The setup of the Switch.To environment can be automated by using the “DeployASPNET.bat” file that is created after running the SetupASPNet.vbs script. The DeployASPNET.bat file is present inside the Views folder (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views) of the respective application.
Note: In an automated setup, the last SwitchTo application executed using the DeployASPNET.bat file will be the first application to come up when accessed from browser.For example, if you execute the DeployASPNET.bat file for Sample1 application first and then for Sample2 application and access the URL, http://localhost/Sample/ default.aspx, then the fireup Ispec of Sample2 application is displayed on the browser, because Sample2 is the last application for which DeployASPNET.bat is executed.
To setup a Switch.To environment automatically, perform the following steps:
Change the website name in the DeployASPNET.bat file, as per your requirement. By default, the website name used in the DeployASPNET.bat file is “Default Web Site”. You can also modify the website name listed in IIS, which has a path as follows:
“%SystemDrive%\inetpub\wwwroot”
Execute the DeployASPNET.bat file. When executing the DeployASPNET.bat file, you will be prompted to provide two inputs, first one is the top level or main directory name (for example, Sample) and the second one is the location of the views folder for the respective switching application (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views).
Execute the DeployASPNET.bat file for each and every application involved in Switch.To and enter the same top level directory name (for example, Sample). However, the location of the views folder varies from application to application.
Open IIS manager and look for the virtual directory under the website name (as mentioned in step 1). It will have the same name as the top level or main directory name (for example, Sample). In case it is not visible, then refresh your website.
Right-click the virtual directory (for example, Sample), select Convert to application, and then click OK.
Enter the following URL in the browser:
http://localhost/Sample/default.aspx
Setting up a Switch.To Environment Manually
The infrastructure provided by the ASP.NET Web Forms Generator and the associated files in the Common and Lang directories allow for application switching to take place between two or more applications. If support for Switch.To is required in the Web Application being developed, then a directory structure must be created to support this deployment. Essentially, a top level directory containing the files and dlls that are common for the total application must be created. Below the top level, a subdirectory for each application that can be switched to containing files for running the application must be created. The required directories should be created according to the following structure:
Sample | |—BIN |—Sample1_aspnet | | | |—lang1033 | |—lang32777 | |—Sample2_aspnet | | | |—lang1033
Each application subdirectory contains files that are specific to the generated application. The application directory contains infrastructure files from the installed "ASP.NETGenerator\Common\Generated" directory. The files generated from the Bundle into the "Views\Lang" subdirectories must be copied to the corresponding "Lang" subdirectories for the application.
To setup a Switch.To environment manually, perform the following:
Create the main application directory (for example, Sample) in a preferred location on your machine (for example, C:\IntePub\WWWRoot).Copy the infrastructure files from the installed "ASP.NET Generator\Common\User" directory to this directory. These files include
UniMenuScript.js
Global.asax.cs
Global.asax
ErrorStrings.cs
Default.aspx.designer.cs
Default.aspx.cs
Default.aspx
DefaultAJAX.aspx.designer.cs
DefaultAJAX.aspx.cs
DefaultAJAX.aspx
CEWFRCommonScript.js
CEASPNETWebForm.sln
CEASPNETWebForm.csproj
BrowserClose.aspx.designer.cs
BrowserClose.aspx.cs
BrowserClose.aspx
Copy the files from the installed ASP.NET Generator\bin directory to Sample\Bin directory. The files include:
UniCombo.dll
UniMenu.dll
CEWebFormRenderer.dll
Copy the Lang folders from the views folder of the switch applications (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views) to the respective newly created switch application folder. For example, consider the first switch application name is Sample1, which has two Lang folders namely lang1033 and lang32777 located in C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views. Copy these Lang folders (lang1033 and lang32777) and place it in the Sample1_ASPNET folder of the newly created main application directory (Sample in the directory structure).
Copy the infrastructure files from the respective views directory of switch applications (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views) into each of the switch application folder (Sample1_ASPNET and Sample2_ASPNET in the above structure). The files include
Close.ascx
Close.ascx.cs
Close.ascx.designer.cs
IspecView.cs
Login.ascx
Login.ascx.cs
Login.ascx.designer.cs
SessionErr.aspx
SessionErr.aspx.cs
SessionErr.aspx.designer.cs
TimeOut.ascx
TimeOut.ascx.cs
TimeOut.ascx.designer.cs
UserControlView.cs
Copy the Web.config file from the Views folder of the first switch application (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\views) to the newly created main application directory (for example, Sample).
Configure the Web.config file to set the ApplicationSwitching option to True for the Switch.To functionality to work. The Web.config file specifies the name of the initial application to connect to.
Copy the CEASPNETWebForm.dll file from the bin folder of the first switch application (for example, C:\NGEN_CE\Classes\com\unisys\Sample1\aspnet\ views\bin) and the <application>_<bundle>_CTRLS.dll file from each bin folder of the switch application to the bin directory (for example, C:\InetPub\WWWRoot\Sample\bin) of the virtual directory set up for switching.
Create an application called Sample and point it to the switch location (for example, C:\InetPub\WWWRoot\Sample) using IIS. In case the virtual directory (for example, Sample) is already listed in IIS, then right-click the virtual directory, select Convert to application, and then click OK.
Enter the following URL in the browser to display the fireup Ispec for the first switch application (Sample1):
http://localhost/Sample/default.aspx
When an application switch occurs at runtime, the host response specifies the application name to switch to (for example, Sample2). Using this application name, in conjunction with the current bundle name, the ASP.NET application can change to using the appropriate set of files (for example, Sample2_ASPNet).