ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data Namespace / ServiceConnectionProperties Class / URL Property
Example

In This Topic
    URL Property (ServiceConnectionProperties)
    In This Topic
    The service URL.
    Syntax
    public Uri URL {get;}
    Public ReadOnly Property URL As Uri
    Example
    Get the Data Connection Properties from a Feature Service
    {
      var featureServiceMapView = MapView.Active;
      if (featureServiceMapView == null)
        return;
    
      await QueuedTask.Run(() =>
      {
        Layer selectedLayer = featureServiceMapView.GetSelectedLayers()[0];
    
        if (selectedLayer is FeatureLayer)
        {
          FeatureLayer featureLayer = selectedLayer as FeatureLayer;
    
          using (Table table = featureLayer.GetTable())
          using (Datastore datastore = table.GetDatastore())
          {
            ServiceConnectionProperties serviceConnectionProperties = datastore.GetConnector() as ServiceConnectionProperties;
    
            if (serviceConnectionProperties == null)
            {
              return;
            }
    
            Uri url = serviceConnectionProperties.URL;      // Will be the URL to the Feature Service.
            string user = serviceConnectionProperties.User;     // The username property will only be
                                                                // populated for feature service hosted
                                                                // on non-federated ArcGIS Server.
            string password = serviceConnectionProperties.Password; // Will always be empty.
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also