Quantcast
Channel: Rick Strahl's FoxPro and Web Connection Weblog
Viewing all articles
Browse latest Browse all 133

Updating Launch.prg to Latest Version in Web Connection

$
0
0

In v6 and later of Web Connection, the launch.prg is a nice easy way to launch your Web Connection application on the local machine, and get all the moving parts started at once without having to individually launch them all:

launch.prg is generated as part of a new project creation using the Web Connection new Project Wizard. It does the following:

  • Starts up the Web Server (IIS Express, Dotnet Core Server)
  • Starts up Web Connection FoxPro Server application (from the FoxPro IDE)
  • Opens a browser and navigates to default page

Here's what this looks like:

Here I'm using the .NET Core based local Web Connection Web Server as the default server, but the launch command can launch any of the supported Web servers by explicitly specifying a Web Server name:

  • launch() - default project config
  • launch("IISEXPRESS")
  • launch("WEBCONNECTIONWEBSERVER") or launch("DOTNETCORE")
  • launch("IIS")

If you run launch() without parameters as I do in the screen capture, the default is used. The default is the server you configured your project for when you ran the New Project Wizard, but it's easy to change this later.

It's a PRG File: Customize it

Because launch.prg is merely a PRG file you can customize the file easily after initial installation. In fact, all the configurable values are defined at the top of launch.prg and you can easily change these values to change the default behavior.

The values that you can change are at the top of the file.

Specifically you can change these values:

*** Changable Project Launch Settings
lcServerType = "WEBCONNECTIONWEBSERVER"  && default if not passed
lcVirtual = "wwThreads"     && used only for IIS
lcAppName = "wwThreads"     && used to launch FoxPro server
llUseSsl = .F.   &&  hard-code. Web Connection Web Server only
lcIisDomain = "localhost"

*** These you usually don't change
lnIISExpressPort = 7000
lnWebConnectionWebServerPort = 5200

The lcServerType is the main thing that you might change in an already created launch.prg file and if you decide to run a different server as your default server. The lcVirtual value is used for IIS if you are running on localhost and specifies the virtual directory such as http://localhost/wwthreads. If you are running IIS at the root folder, leave this value as an "" empty string. The lcAppName is used to launch the FoxPro server with DO wwThreadsMain. If you prefer to run an EXE, you can change the logic at the very bottom of launch.prg to remove the Main from the following commands:

? "Server executed:"
? "DO " + lcAppName + "Main.prg"

*** Start Web Connection Server
DO ( lcAppName + "Main.prg")

lUseSsl applies only to the .NET Core Web Connection Web Server which can easily run under the https protocol. IISEXPRESS can also run under SSL but it has to be configured at the server level which is not done by default.

The lcIisDomain lets you specify a custom domain or IP Address for your server if you don't want to run on localhost. This will allow you to access multiple sites with host headered names when using IIS which is useful if you run with IIS.

The IISEXPRESS and .NET Core Web Connection Web Server can also choose a specific port to run under when started and specifying the port will launch on that port and then launch the browser on that port. Typically you don't need to change this port unless you work on multiple Web Connection applications at the very same time. Note that if you re-use the same port with multiple sites, you may have to do a hard browser refresh (ctrl-shift-r) to force the browser to refresh all cached resources to show the appropriate site resources.

Trick: If you often switch Servers use Intellisense Shortcuts

I use a few Intellisense shortcuts for various launch operations:

  • LI - Launch IISExpress
  • LN - Launch None (doesn't launch a Web Server but everything else)
  • LW - Launch the Dotnet Core Web Connection Web Server

Don't have a Launch.prg or an old version?

If you don't have a launch.prg in your project because you have a really old project, or you have an old out of date version, you can still take advantage of this functionality by essentially creating a new launch.prg file as part of a new project and then copying the file.

You should be able to use launch.prg with any project that is v6 or later, and it might even work with older projects although you'll have to stick with IIS and IIS Express for those.

The easiest way update a project with a new and current launch.prg file is:

  • Create a new Project in the New Project Wizard
  • Choose IIS Express or Web Connection Server for lowest install impact
  • Go through the Wizard
  • Go to the project's folder
  • Copy launch.prg
  • Paste into your projects Deploy folder
  • Update the configurable variables at the top of launch.prg
  • If you want delete the newly created project folder

Projects by default are created in \WebConnectionProject\YourProject and with v6 and later projects are fully self contained in that folder structure. If you didn't configure for IIS, you can simply delete the folder and everything related to the project is gone - there are no other resources used on the machine. This of course is one benefit of the new project system in that provides a single, fully portable directory hierarchy that you can easily move to a new location.

As far as launch.prg is concerned, it's pretty much a generic program file that can just be copied verbatim from the generated project into another location. You can then use the configuration settings mentioned above to customize for your specific application. Typically you'll only need to change the lcServerType and lcAppName and lcVirtual values.

Summary

To me launch.prg is a very simple, but extremely time saving utility in Web Connection. It makes it easy for new users to get started, makes it easier to not forget to launch one part of the application, and most importantly can save a lot of time to start up an application consistently. You can use the same command for each application, which makes it convenient and easy to shortcut the commands via Intellisense to make it even easier.

this post created and published with the Markdown Monster Editor

Viewing all articles
Browse latest Browse all 133

Trending Articles