Introduction
It is possible to create a client side Google Web Toolkits
(GWT) project (which is in JavaScript) and access this from within a C# .NET
project. There are two things you need to understand.
1) You
can embed any custom JavaScript into a .NET Web page and this can then be
invoked
2) You
will need to fully manage the rendering of the webpage yourself (using standard
web call backs). You cannot rely on any built in post back mechanism in .NET
3) You
must know how to communicate with the Google Web Toolkit part of the project
Please note, in the discussions below, the key elements
of a working project have been extracted to give you a reasonable idea of how
to proceed yourself. It is possible the code will not compile without some
modifications.
Visual Studio (Server) side
The key element of the Visual Studio project is to have two
web pages for each web application. The first page is used to render the
application and the second (background) page is used to communicate with the
application. In other topics, these pages are called
·
Default.Aspx
·
Response.Aspx
Note in this web site there is only one master web
application which is used to start all the other web applications. This means
we only need to use the two web pages mentioned above. The master web application
is called the Application Selector. It is a normal application
just like the other ones.
Optimise Loading Time
Most modern browsers support receiving input as compressed
‘GZip’ format. There is a useful function that allows you to easily embed this
concept into your Visual Studio pages. This is particularly valuable when
sending data to the client from the server. The following code is taken from
this web site. It works, so just paste it into your project.
http://csharpfeeds.com/post/5518/HttpWebRequest_and_GZip_Http_Responses.aspx
|
private
bool IsGZipSupported(Page
page)
{
string AcceptEncoding = page.Request.Headers["Accept-Encoding"];
if (!string.IsNullOrEmpty(AcceptEncoding)
&&
(AcceptEncoding.Contains("gzip")
|| AcceptEncoding.Contains("deflate")))
return true;
return false;
}
private
void GZipEncodePage(Page
page)
{
if (IsGZipSupported(page))
{
string AcceptEncoding = page.Request.Headers["Accept-Encoding"];
if (AcceptEncoding.Contains("gzip"))
{
page.Response.Filter = new
System.IO.Compression.GZipStream(page.Response.Filter,
System.IO.Compression.CompressionMode.Compress);
page.Response.AppendHeader("Content-Encoding",
"gzip");
}
else
{
page.Response.Filter = new
System.IO.Compression.DeflateStream(page.Response.Filter,
System.IO.Compression.CompressionMode.Compress);
page.Response.AppendHeader("Content-Encoding",
"deflate");
}
}
}
|