ThinkGeo.com    |     Documentation    |     Premium Support

ArcGISServerRestLayer Header Settings

Hello,

We have been using the ArcGISServerRestLayer to access NOAA’s nowCoast layers. After a change that they made, we can no longer access them without setting the User Agent header item. However, ArcGISServerRestLayer does not allow for the setting of header items, just parameters on the URL.

Is there a way to set header items that I’m missing? If not, can the ArcGISServerRestLayer be updated to allow for this?

Thanks,
Dib

Hi Dib,

You can modify the sending request to append any information you want:

ArcGISServerRestLayer arcGISServerRestLayer = new ArcGISServerRestLayer();
        arcGISServerRestLayer.SendingWebRequest += Agrl_SendingWebRequest;

    private void Agrl_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
    {
        e.WebRequest.Headers.Add("", "");
    }

Regards,

Don

Don,

Thanks for the starting point. Here is how I got it working:

AddHandler Me._arcGISLayer.SendingWebRequest, AddressOf Me.Agrl_SendingWebRequest

Friend Sub Agrl_SendingWebRequest(sender As Object, e As SendingWebRequestEventArgs)
    DirectCast(e.WebRequest, Net.HttpWebRequest).UserAgent = "AgentNameHere"
End Sub

Hi Dib,

I am glad to hear that’s helpful. Any question please let us know.

Thanks
Mark