Step 1 - Creating a new project

The first step to create a brand new application is by creating a new project for your application. To do so start the West Wind Management Console from the VFP command window:

Click on the Create New Project button to create a new Visual FoxPro project that includes the base Web Connection framework classes and the startup code.

Note to shareware users:
The Shareware version cannot build a Visual FoxPro project or EXE file due to the fact that the shareware version is precompiled. The full version comes with source code and allows to create a 'real' project. However, you can still run the application by simply running the PRG files as mentioned below.

In the Wizard that pops up start by naming the project and the main process class. The project name should be the filename of the project you want to create. Use a single string value without spaces for this setting. In this case it's WebDemo.

The filled out page now looks like this:

A Process is the actual request handler class, where you will write your logic to handle Web requests. A single project can contain several Process classes. In this case we're going to create a new project and add our first Process class called WebDemo. You can later add additional Process classes using the New Process Wizard.

To make it real obvious which pieces I'm talking about in this demo I'll name the project WebDemo and the process WebProcess.

I also need to specify the Web server I'm planning on using, in this case IIS 6. Note that it's important that you pick the correct Web Server, especially in the case of IIS 6. IIS 6 is heavily locked down and this Wizard sets up a number of settings to make sure that your new project can run.

Step 2 of the Wizard now asks you to set up the Web directory for this application by creating a virtual directory, copying the Web Connection ISAPI connector to it and configuring the application settings for the new application.

The filled out dialog looks like this:

Note that the Web path can be anywhere but should point somewhere into your Web directory structure. Above the default \inetpub\wwwroot\ basepath is chosen with the virtual created off that. The Temp file path is open to your choice, but make sure that the directory allows FULL access user rights to the IUSR_ account or Everyone so that the ISAPI extension can read and write files to this directory.

Step 3 lets you configure a script map for your application. A script map is a file extension that maps to the Web Connection ISAPI DLL that makes it easier to reference requests. Once mapped any request to a 'file' or URL with this extensions maps to the Web Connection DLL.

Start with the extension you want to use for the script map. WP is good for example of WebProcess. The path to the DLL is automatically filled and defaults to the BIN directory of your new virtual directory. You can change the path, but generally you'll want to leave this setting as is.

Go to the last page of the Wizard and click on the finish button to let the Wizard generate the project for you now. When you're done the Wizard will popup the project for you to review.

Very Important
A Project file will not be built when you run CONSOLE.EXE from Explorer as the VFP runtime cannot create a project. You have to run this process from within Visual FoxPro to create a new project. If you run the EXE directly you can manually create the project after the fact by adding <yourapp>Main.prg to a new project called <myApp>.pjx and recompiling all files from the project.

The project may not compile completely at this time due to some files being in use. You may see a few errors for files that are used by the currently running program especially files like File2Var, IsDir, OpenExclusive etc. These files are located in wwUtils.prg and will be pulled when the project is recompiled. After the Wizard completes exit the Management Console and issue BUILD EXE <project> FROM <project> from the VFP Command Window to recompile your project or reopen and compile the project.

Shareware version users
The shareware version does not build a project file as it is precompiled and can't add the Web Connection source files to the projects. Therefore you can't build an EXE. However you can still run the project successfully by running the main PRG file for the application: DO <yourproject>Main.prg. In fact, this is how we usually debug our applications anyway - there's no need to build an EXE until you're ready to deploy the application.

As the project is being generated each of the files is pulled into the project and compiled. When the compilation step is completed a dialog will pop up asking whether you want to register the component with DCOMCNFG. If you're running on Windows NT choose yes, otherwise no. This operation sets the configuration of the COM object to Interactive User impersonation to allow the COM object to be visible on the desktop.


Moving your new Project

The New Project Wizard creates all of the generated files in the current directory which is the Web Connection install directory. If you're only building one or a few separate applications this is probably fine, but if you create a lot of applications, you probably want to break out the project into a separate directory.

You can move the files to another location if you choose as long as you make sure that you can still access them from the WC root via the FoxPro Path (SET PATH TO). For example, I typically stick new projects into a subdirectory of the WC root so for example I have a \webdemo directory off the WC root. It's up to you what you move - I tend to leave the project and main file (WebDemoMain.prg) in the WC root so I can start the project easily without having to set the path first. But I move the Process class and any data files and other support files the application uses into a separate directory (I do this for separate process classes as well) so that each of these applications is isolated and self-maintainable. The only files that stay in the root are the project related files and the main program file, so that the file can be started up simply by typing DO <yourproject>main.prg, instead of having to prefix a path first.

It's very important that if you do move the application you add a SET PATH TO (<moved path>) into your SetServerProperties method of the server so that the running server application will be able to find your moved program files and any data you may also put in the subdirectories. SetServerProperties can be found in your generated <yourproject>main.prg file and contains application specific setting such as SET PATH, SET CLASSLIB and so on that affect the environment that the application runs in. Here you should add your new moved application path.


  Last Updated: 2/11/2008 | © West Wind Technologies, 2008