HttpContext, HttpRequest, HttpResponse Abstraction

From Visual WebGui Wiki

Jump to: navigation, search


Contents

Overview

NOTE - This information is valid only for version 6.4.0Beta3 and later versions of Visual WebGui

As a part of release 6.4 of Visual WebGui, we are extending the framework to run application on more software platforms than ASP.NET. This will allow you to run Visual WebGui application with WCF service, or some other simple Http server as the backbone. As a part of these extensions, starting with Visual WebGui 6.4.0Beta3, an abstraction layer was added for accessing the ASP.NET specific objects which now become HostRequest, HostResponse and HostContext instead of earlier HttpRequest, HttpResponse and HttpContext

The changes made to implement the abstraction, are backwards compatible for all Components of the framework, with one exception, the DataBaseResourceHandle.

Best practice for 6.4.0Beta3 and all later version, is to not use "Http" prefixed properties directly, rather use the abstraction layer.

Details

The abstraction is made as simple as possible, by having parallel naming conventions for the abstraction layer. Thus, for every reference to HttpContext, you simply replace it with HostContext and so forth. The properties being abstracted can be seen in the following table:

New abstraction properties
Old direct method
HostContext
HttpContext
HostRequest
HttpRequest
HostResponse
HttpResponse

Although the abstracted properties provide you will all the same functionality as the ASP.NET ones did before, you can still get to the original ASP.NET objects via the abstracted ones as HostContext.HttpContext would return the ASP.NET HttpContext object etc.

For now, using ASP.NET webservers, the old way of directly accessing the ASP.NET properties, is backwards compatible with existing applications, meaning that you can run your existing applicatons without changing them (except for DatabaseResourceHandle) but best practice strongly advices you to switch to using the abstraction layer to make your application more portable and to prevent future problems.

DatabaseResourceHandle

As mentioned before, there is one exception to the backwards compatibility rule, the DatabaseResourceHandle. This resource handle requires you to use the abstraction layer, instead of directly accessing the ASP.NET "Http" prefixed properties. Thus, inside that class, make sure you use HostContext, HostRequest and HostResponse.

Some of the overridable methods of the DatabaseResourceHandle class are now only supplied with a Gizmox.WebGUI.Hosting.HostResponse typed parameter, so this will automatically force you to use the abstraction layer, but the class it self still has a this.Context.HttpContext access to the ASP.NET object directly. Please don't use it, use the this.HostContext instead.

See also

Rererences

Articles

Videos

Code samples

Forum discussons

Other references

Personal tools