.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

bypass proxy using c#

Posted By: kamlesh     Posted Date: November 22, 2011    Points:5   Category :C#
hi.
i want to bypass proxy using C# how to do it please help me...

Responses
Author: Pankaj Chahar             
Posted Date: November 26, 2011     Points: 20   

Hi,


There are many like me who are behind the Proxy and many time you are not able to use the recent Data in your Program from Web as your are not able to retrieve that data because of Proxy coming in between. As finally here is the solution for all those Web Savvy Programmers to byPass Proxy.

There are two Code mentioned here first in which you only need to byPass Proxy and no Authentication Required.

Source Code:

// Source Code starts
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E)
{
myPage.Text = readHtmlPage(http://www.c-sharpcorner.com);
}
private String readHtmlPage(string url)
{
String result;
WebResponse objResponse;
WebProxy proxyObject = new WebProxy("http://urproxy:port/",true);
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objRequest.Proxy = proxyObject;
objResponse = objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
</script>
<html>
<body>
<b>This content is being populated from a separate HTTP request to
<a href="http://www.c-sharpcorner.com">www.c-sharpcorner.com</a></b><hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>
// Source Code End
//While Here is the Code where you need to Provide UserName,Password and //domainName if your Proxy requires these Authentication Mode.
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E)
{
myPage.Text = readHtmlPage(http://www.c-sharpcorner.com);
}
private String readHtmlPage(string url)
{
String result;
HttpWebRequest makeReq =(HttpWebRequest)WebRequest.Create(http://www.shivanicreations.com/);
NetworkCredential giveCred = new NetworkCredential
("username","password","domain");
CredentialCache putCache = new CredentialCache();
putCache.Add(new Uri("http://www.shivanicreations.com/"), "Basic", myCred);
makeReq.Credentials = myCache;
WebResponse objResponse;
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
</script>
<html>
<body>
<b>The below given Page is generated from a separate Request to this URL
<a href="http://www.c-sharpcorner.com">www.c-sharpcorner.com</a></b>
<hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>



Pankaj Chahar

Deserve More...


Author: kamlesh             
Posted Date: December 28, 2011     Points: 20   

Client : SPSOFT Software Technology Pvt. Ltd.
Environment : Windows Platform: C#.Net, Visual C++, SQLite, Windows server 2003/2008,
Exchange Server 2003/2007/2010, SQL Server and Oracle
Duration : Running
Testing : Manual Testing.
Team Size : 3
Description :
SPProtect is the Product designed and developed on client server architecture to provide Backup/Restore and Sync solution to the clients on local or remote Storage location (Server/Cloud/USB). The product specifies the backup and restore with synchronization functionality for various proprietary software available in the market and store these backups to Local/Remote Server or to external attached device or to the Cloud Storage.
The featured product facilitate:
-Backup and Restore- Files and Folders of Local System
Databases- Exchange Server 2003/2007/2010, SQL Server, Oracle, Exchange Granular
-sync Manager- Files and Folders of Local System
Databases- Exchange Server 2003/2007/2010, SQL Server, Oracle, Exchange Granular
 Responsibility:
Design and develop test cases and execute it manually.
Functional and Regression testing.
System Testing.
Responsible for Defect reporting, tracking and retesting the reported defects.
Updation of Test Case document for Application.

Thanks And Regards.
Kamlesh Nikam


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend