2

I am developing a Windows phone mobile application. I need to send a WebRequest for a specific URL. See below

HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create(@"http://www.test.html");

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    if (response.StatusCode == HttpStatusCode.OK)
        return true;//site available
    else
        return false;
}

Obviously, It works well for network without proxy. For network using proxy, I need to add the proxy information along with Webrequest. Since we are doing phone applcaition, We cant hardcode the proxy address in the Webrequest object. How to send the Webrequest where the network is using proxy(from Windows phone application)

Chubosaurus Software
  • 8,133
  • 2
  • 20
  • 26
Anees Deen
  • 1,385
  • 2
  • 17
  • 31

1 Answers1

0

So far I couldn't find answer for it. However, I have handled the proxy in my desktop application. you need to add the following settings in you app.config file. This settings will add proxy information in all your WebRequest calls. Not sure whether this could help for your mobile app!

<?xml version="1.0"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
  <!--Provide your Proxy address-->
  <system.net>
    <defaultProxy>
      <proxy
        proxyaddress="[IP Address]:[port]"        
    />
    </defaultProxy>
  </system.net>
</configuration>
Anees Deen
  • 1,385
  • 2
  • 17
  • 31