Friday, June 6, 2008

homepage takes too long to load

this is the most common problem we face and most often we keep the page small in size and use less images.

But, what if my homepages a lot of stuffs to get loaded which is a must requirement? The only thing you can do it to Ajax it! you need to separate a page into several html block of codes and load it separately.

What i did is using the ASP.NET AJAX update panel to warp the html code and use timer to load it later. I think this is not really a correct why but it is better then doing nothing.

What else i can do? do you have any solution suggest for me?

Sunday, June 1, 2008

A simple way to get a content from an URL over the internet

sometimes we want to get the content over the internet and process the content, here is a super simple method that i discovered.


using System.Net;
using System.IO;

public static string GetWebContentString(string
url)
{
HttpWebRequest httpReq =
(HttpWebRequest)WebRequest.Create(url);
HttpWebResponse httpRes =
(HttpWebResponse)httpReq.GetResponse();
Stream fs =
httpRes.GetResponseStream();
StreamReader sr = new
StreamReader(fs);
return sr.ReadToEnd();
}