Using CreateSelectionLayer For ArcGIS Server

Discussion created by mhadi11 on Jul 25, 2013
I am trying to create a layer by using selecting features. I am connecting to ArcGIS server using ESRI.ArcGIS.ADF.Connection.AGS.So far I have managed to get following code running. But it is not creating layer on the server. I do understand that I need to create this layer using server context but I am not able to find any examples other than CreateSelectionLayer.
What am I missing? Is there an alternate way to perform this?
        public bool CreateLayerFromSelection(IServerContext sc, string LayerName, bool UseCurrentSelection)
            IFeatureLayerDefinition2 pFeatureLayerDef = (IFeatureLayerDefinition2)_featureLayer;
            IFeatureLayer pSelectionFeatureLayer = pFeatureLayerDef.CreateSelectionLayer(LayerName, UseCurrentSelection, "", "");
            return true;