c# system.net.httpwebrequest error

My head is swimming...

VS 2008 Express with c#
I have added System.Net in the References, and included "Using System.Net" in the service1.cs file.  I'm working in the service1.Designer.cs file.

Every indication is that you have to do:

HttpWebRequest objRequest;
objRequest = (HttpWebRequest)WebRequest.Create("http://www.mysite.com/x.aspx");

First of all,
HttpWebRequest objRequest;  <-- gives error

So I add the explicit reference to (Sytem.Net):

System.Net.HttpWebRequest objRequest;  <-- no error

I also added the reference in the "objRequest =" line but I *STILL* get an error on the WebRequest:

objRequest = (System.Net.HttpWebRequest)WebRequest.Create("http://www.mysite.com/x.asp");

The error is: WebRequest does not exist in the current context.


Who is Participating?
Gagan_JauraConnect With a Mentor Commented:
objRequest = (System.Net.HttpWebRequest)WebRequest.Create("http://www.mysite.com/x.asp");
objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://www.mysite.com/x.asp");
snowdog_2112Author Commented:
I fxed it.  

First, I found syntax to make it work:

System.Net.HttpWebRequest objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(sURL);

This led me to believe the "using System.Net" was not inherited from the service1.cs file to the .designer file.

I had to include in the service1.designer.cs file:

using System;
using System.Configuration;
using System.Net;
using System.IO;

Now I can refer to them without referencing the full path.

snowdog_2112Author Commented:
See my post below this answer about including "using System.Net" in the service1.designer.cs file - this answer fixed my error, but including the System.Net makes it easier to code without having to include the full path.
All Courses

From novice to tech pro — start learning today.