How to render any web site page on Your web page
Hi friends
To day i have some thing new code for you in this i'll show you how to get or render any web page like yahoo.com home page or any xyz web page on your web application .aspx page . hope it sound interesting to you.
1) Lets start first create any web application and create a web page ex. New.aspx thats my aspx page where i want to render http://itneeds4u.blogspot.com/ website home page .
2) After creation of that page put a lable on it and set Text property =This is a Lable . after this run this page you will get a page out put like this ..
After this put a code at the page load of New.aspx.cs
public partial class New : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. Here we used to create entire input
StringBuilder sb = new StringBuilder();
// used on each read operation
byte[] buf = new byte[8192];
// Here We requet for that page which we want to render on our web page
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://itneeds4u.blogspot.com");//Put your url here
// This wil execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// Here this object read data from responce strem
Stream responseStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// Here fill the Buffer with data
count = responseStream.Read(buf, 0, buf.Length);
if (count != 0)
{
// Here we translate bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);
// Create a Proper web text.
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
lblOutput.Text = sb.ToString();
}
}
after this the web site page will render on your simple aspx page and it will show on the lable .and after this your New.aspx will be look like this .
this kind of code also help you to find any specify information from other page also..
hope this information is helpful to you.
Regards,
Rajesh
To day i have some thing new code for you in this i'll show you how to get or render any web page like yahoo.com home page or any xyz web page on your web application .aspx page . hope it sound interesting to you.
1) Lets start first create any web application and create a web page ex. New.aspx thats my aspx page where i want to render http://itneeds4u.blogspot.com/ website home page .
2) After creation of that page put a lable on it and set Text property =This is a Lable . after this run this page you will get a page out put like this ..
After this put a code at the page load of New.aspx.cs
public partial class New : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. Here we used to create entire input
StringBuilder sb = new StringBuilder();
// used on each read operation
byte[] buf = new byte[8192];
// Here We requet for that page which we want to render on our web page
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://itneeds4u.blogspot.com");//Put your url here
// This wil execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// Here this object read data from responce strem
Stream responseStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// Here fill the Buffer with data
count = responseStream.Read(buf, 0, buf.Length);
if (count != 0)
{
// Here we translate bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);
// Create a Proper web text.
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
lblOutput.Text = sb.ToString();
}
}
after this the web site page will render on your simple aspx page and it will show on the lable .and after this your New.aspx will be look like this .
this kind of code also help you to find any specify information from other page also..
hope this information is helpful to you.
Regards,
Rajesh
very nice...creative
ReplyDelete