Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim response As HttpResponse = context.Response Dim uri As String = HttpUtility.UrlDecode(context.Request.Url.Query.Substring(1)) If Not uri.Contains(urlStr) Then response.StatusCode = 500 response.StatusDescription = "Wrong url detected" response.Write("This proxy page is dedicated to a single url.") response.End() Return End If Dim req As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(uri), System.Net.HttpWebRequest) req.Method = context.Request.HttpMethod req.ServicePoint.Expect100Continue = False If context.Request.InputStream.Length > 0 Then Dim bytes(context.Request.InputStream.Length) As Byte context.Request.InputStream.Read(bytes, 0, context.Request.InputStream.Length) req.ContentLength = bytes.Length Dim contType As String = context.Request.ContentType If String.IsNullOrEmpty(contType) Then req.ContentType = "application/x-ww-form-urlencoded" Else req.ContentType = contType End If Using outputStream As Stream = req.GetRequestStream() outputStream.Write(bytes, 0, bytes.Length) End Using End If Dim serverResponse As System.Net.WebResponse = Nothing Try serverResponse = req.GetResponse() Catch webExc As System.Net.WebException response.StatusCode = 500 response.StatusDescription = webExc.Status.ToString() response.Write(webExc.Response.ToString()) response.End() Return End Try If Not serverResponse Is Nothing Then response.ContentType = serverResponse.ContentType Using byteStream As Stream = serverResponse.GetResponseStream() If serverResponse.ContentType.Contains("text") Or serverResponse.ContentType.Contains("json") Then Using sr As StreamReader = New StreamReader(byteStream) Dim strResponse As String = sr.ReadToEnd response.Write(strResponse) End Using Else Dim br As New BinaryReader(byteStream) Dim outb() As Byte = br.ReadBytes(serverResponse.ContentLength) br.Close() response.CacheControl = "no-cache" response.OutputStream.Write(outb, 0, outb.Length) End If serverResponse.Close() End Using End If response.End() End Sub
<esri:ArcGISTiledMapServiceLayer ID="David'sLayer" ProxyURL="http://serverapps.esri.com/SilverlightDemos/ProxyPage/proxy.ashx" Url="http://sunlight.wygisc.uwyo.edu/ArcGIS/rest/services/Base_Data/MapServer" />
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.