aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Tuesday, April 5, 2011 Total Views:  

I have noticed that many developers have problems when they face “407 Proxy Authentication Required” exception on the internet by application. Your application required proxy server when you use your application behind the LAN.


In net 1.1 GlobalProxySelection class allows you to return WebRequest.DefaultWebProxy.

You can also prompt the user for the own credential, or you can also set the default credentials. I will also advice you that don’t set credentials until you will not receive 407 exception message.


There are some other examples but at the time this will helps you. Next time I will publish some more examples on this error, if you have more concerned please feel free to ask.

Example

        System.Net.WebRequest request = System.Net
                             .WebRequest.Create("http://www.aspxtutorial.com/Default.aspx");

        System.Net.WebProxy pry = new System.Net.WebProxy("PROXY ADDRESS", 8080);

        pry.Credentials = System.Net.CredentialCache.DefaultCredentials;

        System.Net.GlobalProxySelection.Select = pry;

 

        System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();

        System.IO.Stream dataStream = response.GetResponseStream();

        System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);

         string responseFromServer = reader.ReadToEnd();

        Response.Write(responseFromServer);

        reader.Close();

        dataStream.Close();

        response.Close();

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5