1 Replies - 10951 Views - Last Post: 07 November 2009 - 07:37 AM Rate Topic: -----

#1 demonfox33   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-October 09

Creating C# web browser without web browser control

Posted 07 November 2009 - 07:28 AM

Hey guyz, I'm takin a beginner's class in C# but the projects are ridiculously hard, like the one I've been given now. It's to create a web browser WITHOUT using the inbuilt browser control in Visual Studio that implements some requirements such as:
sending HTTP request messages for URLs typed by user.
Receiving HTTP response messages & display contents of the messages on the interface.
allowing user to create & edit HomePage URL, & should be loaded on startup.
allowing user to create a list of Favourite webpages.
Maintaining History.
Create tabs on the browser.
Moreover, the professor has said use the Apache web server for backend and use multithreading in the development of the web browser to separate the browser-server communication from the GUI support.
I've spent 2-3 days surfing the web for help but everywhere I see ppl using the inbuilt control, which is not exactly helpful plus my limited knowledge on C# & lack of teacher support, so I would definitely appreciate if I could get some ideas on how to go about this project.
For the design, I created a toolstrip with buttons for back, forward, refresh webpage, stop, homepage, Go button & a textbox to type the URL. Beneath the toolstrip, I inserted a textbox to show the webpage content. On the click of the Go button, I inserted the following code to load the webpage requested by user (eg: http://www.google.com):

// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(this.urlTxtBox.Text);
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse= (HttpWebResponse)myRequest.GetResponse();

// Display the contents of the page to the console.
Stream streamResponse=myHttpWebResponse.GetResponseStream();
// Get stream object
StreamReader streamRead = new StreamReader(streamResponse);

Char[] readBuffer = new Char[256];
// Read from buffer
int count = streamRead.Read( readBuffer, 0, 256 );
while (count > 0)
{
// get string
String resultData = new String( readBuffer, 0, count);
// Write the data
textBox1.Text += ( resultData );
// Read from buffer
count = streamRead.Read( readBuffer, 0, 256);
}

// Release the response object resources.
streamRead.Close();
streamResponse.Close();
// Close response
myHttpWebResponse.Close();

If someone can point me in the right direction to creating some aspects of this project & providing code/links, that would be great as I'm totally stumped.
Thanks in advance,
Vick

Is This A Good Question/Topic? 0
  • +

Replies To: Creating C# web browser without web browser control

#2 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: Creating C# web browser without web browser control

Posted 07 November 2009 - 07:37 AM

Are you sure you're not allowed to use the WebBrowser control at all??

You can do all of the above (tabs etc) and still use the WebBrowser control.. I don't see how he plans on you actually displaying the page you've manually downloaded, have you asked him?!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1