Select to view content in your preferred language

The remote server returned an error

6129
12
06-15-2010 07:08 AM
Sravan_KumarUddarraju
Emerging Contributor
Hi,

I am trying to access WMS and KML services (based on online-samples) in my WebApp, able to access them without any issue from my localhost. Then I published into test server and trying to access my WebApp from server then I am getting following error.

I installed fiddler and to see the error.
  �??The remote server returned an error: (401) Unauthorized.�??
Machine-Name  /Testing/ProxyHandler.ashx?http://mw1.google.com/mw-earth-vectordb/disaster/gulf_oil_spill/kml/noaa/nesdis_anomaly_rs2.kml

Regrds,
Srv
0 Kudos
12 Replies
DanielWalton
Frequent Contributor
It appears that the /Testing/ folder you installed your proxy handler in does not have anonymous access enabled.

-Dan
0 Kudos
Sravan_KumarUddarraju
Emerging Contributor
I checked and Testing Virtual directory has anonymous access enabled. Even I tried testing by turned-off firewall, but no luck.
0 Kudos
DanielWalton
Frequent Contributor
I checked and Testing Virtual directory has anonymous access enabled. Even I tried testing by turned-off firewall, but no luck.


Try putting a dummy html file in the testing folder and see if you can open it with a browser. That will tell you if the problem is related to folder permissions or if there's a problem with your .ashx handler.

-Dan
0 Kudos
Sravan_KumarUddarraju
Emerging Contributor
Thanks for reply. As you said, I copied text file where the ProxyHandler.ashx is reside and tried to browse and I am able to see the content of the text file in the browser (http://Machine-Name/Testing/err.txt).

Here is complete description of the error from Fiddler, when I try to access site (not txt file).

Srv

<html>
    <head>
        <title>The remote server returned an error: (401) Unauthorized.</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>Server Error in '/Testing' Application.<hr width=100% size=1 color=silver></H1>

            <h2> <i>The remote server returned an error: (401) Unauthorized.</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

            <br><br>

            <b> Exception Details: </b>System.Net.WebException: The remote server returned an error: (401) Unauthorized.<br><br>

            <b>Source Error:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>

Line 35:         }
Line 36:
<font color=red>Line 37:         System.Net.WebResponse res = req.GetResponse();
</font>Line 38:         context.Response.ContentType = res.ContentType;
Line 39: </pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <b> Source File: </b> c:\inetpub\wwwroot\Testing\ProxyHandler.ashx<b>    Line: </b> 37
            <br><br>

            <b>Stack Trace:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>

[WebException: The remote server returned an error: (401) Unauthorized.]
   System.Net.HttpWebRequest.GetResponse() +5314029
   ProxyHandler.ProcessRequest(HttpContext context) in c:\inetpub\wwwroot\Testing\ProxyHandler.ashx:37
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75
</pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <hr width=100% size=1 color=silver>

            <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016

            </font>

    </body>
</html>
<!--
[WebException]: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at ProxyHandler.ProcessRequest(HttpContext context) in c:\inetpub\wwwroot\Testing\ProxyHandler.ashx:line 37
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
0 Kudos
DanielWalton
Frequent Contributor
So what's on line 37?

-Dan
0 Kudos
dotMorten_esri
Esri Notable Contributor
Remember that Silverlight doesn't automatically sets credentials to a server like the webbrowser does, so just hitting the file directly doesn't really tell you anything (however you can see this happening in Fiddler where you should first see a 401 request, and then a second request with the auth header).

See the challengerequest approach here: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/02/15/How-to-use-secure-ArcGIS-Server-se...
0 Kudos
Sravan_KumarUddarraju
Emerging Contributor
Please find attached ProxyHandler.ashx.

Line 37 is
        System.Net.WebResponse res = req.GetResponse();

Srv
0 Kudos
dotMorten_esri
Esri Notable Contributor
Aaah so it's not connecting to your proxy that's the issue. Its the proxy connecting to the service that is the problem. Did you set credentials on the request that the proxy is doing? You shouldn't call GetResponse() if there isn't a valid response.
0 Kudos
Sravan_KumarUddarraju
Emerging Contributor
Thanks for quick responses.

Actually I have not set any credentials. Do I have to set user credentials to the WebClient Object?

WebClient client = new WebClient();
client.DownloadStringCompleted += client_DownloadStringCompleted;
client.DownloadStringAsync(wmsUrl);

Srv
0 Kudos