Visual Studio Web Server, Cassini and the Managed Module

The Web Connection Module can be used in combination with the Visual Studio Web Server as well as with a customized and redistributable version of the Cassini Web server that is essentially the same code base. Use of these servers requires that .NET 2.0 is installed and requires use of the Web Connection Managed Module instead of the ISAPI extension. By using these local only servers you can develop without requiring a full Web Server installation like IIS or Apache.

Bundling the Cassini Web Server
Microsoft also provides a standalone version of the Visual Studio Web Server in the form of a source code distributed Cassini server that is essentially the same server (though unsupported). We have bundled a customized version of this server with Web Connection and you can start this server from the Web Connection menu in FoxPro or from the VisualStudio/InternalServer directory. To register the server you have to run GAC.BAT to register the required Cassini component into the registry.

The VS Web Server can also be run without Visual Studio actually running optionally.

Automatic Installation and running in Visual Studio

The Visual Studio Web Server can be used with the Setup and New Project Wizards. Because the server is standalone it will choose a fixed path (c:\websites\<yourVirtual>) by default for the Web path, but you can put the Web directory anywhere you choose. Since it's only file based the only configuration made is configuring the scriptmap you specified.

Once set you can simply open the project in Visual Studio and press Run to execute the Web application (or View In Browser on the Default.htm page) or press Ctrl-F5 to start the Visual Studio Web server on your Web project. You will likely get a compilation error due to the fact that you have Visual FoxPro code in your markup pages which won't compile - ignore the error and set the checkbox to to not show the dialog next time.

From thereon in everything should just work. Note if you Run the Web application you will get many errors potentially - because these projects aren't really ASP.NET code this is normal and you should simply ignore the errors and choose Yes to run anyway to start the site.

The server stays running in the task tray until you explicitly shut it down or close Visual Studio. You can see the port number when hovering over it or clicking on the icon which brings up a small configuration form.

Please note that Web Connection's Show in Web Browser will not work unless you modify the AppSettings key in web.config:

<appSettings> <add key="FoxProjectBasePath" value="c:\wwapps\wc3\"/> <add key="WebProjectBasePath" value="c:\westwind\wconnect\webcontrols\"/> <add key="WebProjectVirtual" value="http://localhost:63841/wconnect/webcontrols/"/> <add key="WebBrowser" value=""/> </appSettings>

But keep in mind that you'll have to change the port each time you restart the VS Web Server. This will be addressed in Visual Studio 2008 which includes an option to set a fixed port for the Web server.

Manually starting the Web Connection Cassini Server

Possibly a better way to start a standalone server is to start it explicitly via the RUN command or a batch file that you launch. If .NET 2.0 is installed you can use the following code from within Visual FoxPro:

DO CONSOLE with "LAUNCHCASSINI","c:\websites\webdemo","81","/WebDemo"

or if you want to manually set these settings:

DO CONSOLE with "LAUNCHCASSINI"

which brings up the server form:

You can click on the link to bring up a browser at this location. You can minimize the appication to the task tray so the Web Server window stays out of your way.

A Url to the server will be:

http://localhost:81/WebDemo/Default.htm

and you should specify whatever path you choose in your web.config configuration for the WebProjectVirtual:

< add key="WebProjectVirtual" value="http://localhost:81/wconnect/webcontrols/"/>

I recommend you create a small PRG file - maybe called LaunchWebServer.prg - and add:

DO CONSOLE with "LAUNCHCASSINI","c:\websites\webdemo","81","/WebDemo"

to start your server quickly and easily.

Manual Setup and Configuration

Automatic configuration is straight forward, but if you already have an app running and want to start using the VS Web Server

Configure the Start Page
The settings in the figure above should be the default except for the default.htm homepage but you can specify any page that you like. The start page can be invoked if you run the site or press Ctlr-F5.

Configure web.config to use the Managed Module
Finally we need to tell the VS Web Server that we want our application extensions to be mapped to the Web Connection module. Add the following to web.config in the project:

<?xml version="1.0"?> <configuration> <configSections> <system.web> <compilation defaultLanguage="C#" debug="false"> <buildProviders> <add extension=".wcsx" type="System.Web.Compilation.PageBuildProvider"/> <add extension=".wcsctl" type="System.Web.Compilation.PageBuildProvider"/> </buildProviders> </compilation> <httpHandlers> <add path="*.wcsx" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule"/> <add path="*.tt" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule"/> <add path="*.wc" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule"/> <add path="*.wwsoap" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule"/> </httpHandlers> </system.web> </configuration>

Both the build providers and the HttpHandlers are required to make this work. Add any script maps you might require in the httpHandlers section. Note that using either Cassini or the Visual Studio Server requires no further configuration as the server runs ALL content through its ASP.NET pipeline. So unlike IIS configuration which requires addition script mapping for ASP.NET the above is all that's needed.

Differences with the Visual Studio Web Server

The Visual Studio Web Server works well enough but it's a fairly limited server. It only knows how to run static content and ASP.NET content. So it can't for example run the Web Connection ISAPI DLL, which is why the managed module is used instead. The server also doesn't support basic authentication which is a problem for testing authentication in Web Connection because the admin permissions are using basic authentication.

To work around this make sure you set the AdminAccount key in web.config to blank ("") so no authentication is applied.


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