Click here to Skip to main content
15,887,175 members
Articles / Web Development / IIS
Article

Smart Client Application based on the No touch deployment

Rate me:
Please Sign up or sign in to vote.
2.25/5 (4 votes)
21 Jun 20064 min read 21.3K   330   17  
Smart Client Application based on the No touch deployment. This kind of application provides you very rich GUI in a Internet zone.

Introduction:

Smart Client Application based on the No touch deployment.

  1. Installing and configuring web service and web site for the smart client application:

    • Unzip and copy the both folders in the wwwroot folder of your machine or to some other folder of your own convenience.
    • On run type intemgr (or open Internet information services manager). Expend till default web sites. Create virtual directory for both web site (Smart client) and web service.
    • Make sure that smartclient.aspx is added in the documents tab.
    • Open tab Directory Security and click on anonymous access and authentication control and click on edit button make sure that Anonymous access check box is checked.
    • Click ok on this form and parent form and close it.
    • Do the same configuration settings for the web services too.

  2. Web site virtual directory property changes to allow exe to execute:

    • Again open internet information services manager (run inetmgr).
    • Click on the virtual directory of the web site (not the web service)
    • View the properties of the virtual directory.
    • Click on configuration button on the directory tab.
    • Click on the add button and add a reference of dll C:\your windows folder \Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll for the .exe extension.
    • Click on ok on all the windows and now exe is ready to be executed from the site.

  3. Config handler project and adding Config handler to the web site:

    • Open the project inside ConfigHandler.zip and build it to make a DLL called Confighandler.dll.
    • Open the project inside SmartClient.zip and add reference of this (Confighandler.dll) in the web site code.
    • Open the web.config file and add the code given below in the web.config file.
      XML
      <httpHandlers>
          <!-- map .exe and .exe?blah.config files to our handler --> 
          <add verb="*" path="*.exe" 
               type="ConfigHandler.ConfigFileHandler, ConfigHandler" /> 
          <remove verb="*" path="*.config" /> 
          <add verb="*" path="web.config" 
               type="System.Web.HttpForbiddenHandler" /> 
      </httpHandlers> 
    • Now build the web site code. You should be able to launch it from the URL: http://localhost/SmartClient/SmartClient.aspx or http://yourMachineName/SmartClient/SmartClient.aspx

    • This helps in removing the error when exe is shown like exename.exe.config.

  4. Accessing web service from the smart client application:

    • Open the project in zip file SmartClientApp.zip and on project menu add a web reference to this to your local web service like http://localhost/mywebserivce/mywebservice.asmx. Rename this web service reference to SerializeMe.
    • Open the app.config file and provide your web service name like
      XML
      <configuration> 
      <appSettings> 
          <add key="AccessSerializeObject.SerializeMe.SerializeWS" 
            value="http://localhost/MySerializableWS/SerializeMe.asmx" /> 
          <add key="WSPath" 
            value="http://work02049/MySerializableWS/SerializeMe.asmx" /> 
      </appSettings> 
      </configuration> 

    Now you can test run this application.

  5. Launching application from the web page:

    • Friends it's as simple as accessing any other webpage from the same or any other site. Just give location of your application in this site and a link tag and you application is ready to work.
    • Place the application in the root folder of your website.
    • <a href=" ./SmartClient.exe">SmartClient.exe</a>
    • You can even pass a parameter to windows application
      HTML
      <a href=" ./SmartClient.exe?PRM=xyz">SmartClient.exe?PRM=xyz </a>

      or multiple parameters to your application like

      HTML
      <a href=" ./SmartClient.exe?PRM=xyz&PRM1=abc">SmartClient.exe?PRM=xyz&PRM1=abc</a>
    • You need different handling for the parameters passed to your application which we are going to discuss in the next section.

  6. Passing parameter to smart client (NTD) application

    • Open smartclientapp project and see there is a file added called WebCommandLineHelper.cs. Any parameter passed to the application will go as a command line parameter and will be received in the main method as arguments. We have to remove the header part and get the name value pare of the command passed to the application.
    • Here is code for accessing and separating these name value pares so that we can access them.
      C#
      string[] args = WebCommandLineHelper.GetCommandLineArgs(argsFromMain); 
      if(args.Length > 0) 
      { 
          for(int j = 0; j < args.Length; j++) 
          { 
              string[] pair = args[j].Split('&'); 
              for (int i=0;i<pair.Length;i++) 
              { 
                  string[] val = pair[i].Split('='); 
                  switch( val[0].ToLower() ) 
                  { 
                      //remore redundand items and check for case dependency 
                  case "prm" : 
                      strUserName = val[1].ToString(); 
                      break; 
                  case "prm1" : 
                      strPRM1 = val[1].ToString(); 
                      break; 
                  case "prm2" : 
                      strPRM2 = val[1].ToString(); 
                      break; 
                  } 
              } 
          } 
      } 
      
      strWSPath = 
          System.Configuration.ConfigurationSettings.AppSettings["WSPath"]; 
    • '=' sign is separator for the name value pare and '&' is separator for the different arguments.

  7. Clearing GAC or changing version of the application every time you rebuild it:

    • Since we have used the strong name for our application it gets stored in the Global assembly cache and when we rebuild it and place it again in the web site folder and try to launch it. It will show your JIT error because there is already an assembly with same name, same version and same strong name available. There are 2 ways you can overcome with this problem. Change the version number in the assembleyinfo.cs file every time you rebuild you application.
      [assembly: AssemblyVersion("1.0.1.6")]
      Or go to .net command prompt (start->programs->Microsoft visual studio .net 2003->visual studio .net tools-> Visual Studio .NET 2003 Command Prompt and type gacutil /cdl

  8. Working with application:

    • When you are finally ready to work on it just type the URL http://localhost/smartclient/
    • There are 3 links on the page in a table which will launch application with no parameters (click on SmartClient.exe link) other with one parameter where user has to specify his/her name (click on Click here SmartClient.exe?prm=xyz link) which will display user name on the title bar. 3rd one with 2 text boxes where user is suppose to give 2 values which will be added when application is launched.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
vinay shanker prasad working in india as a software developer.

Comments and Discussions

 
-- There are no messages in this forum --