public void AddRasterLayerToMap(string Path,string FileName,IServerContext pMapServerContext)
{
IMap pMap;
IRasterLayer pRasterLayer;
IWorkspaceFactory pWorkspaceFactory;
IRasterWorkspace pRasterWorkspace ;
IRasterDataset pRasterDataset ;
IMapServer2 pMapServer ;
IMapServerObjects2 pMapServerObjects2;
pWorkspaceFactory = (IWorkspaceFactory)pMapServerContext.CreateObject("esriDataSourcesRaster.RasterWorkspaceFactory");
pRasterWorkspace = (IRasterWorkspace)pWorkspaceFactory.OpenFromFile(Path, 0);
pRasterDataset = pRasterWorkspace.OpenRasterDataset(FileName);
pRasterLayer = (IRasterLayer)pMapServerContext.CreateObject("esriCarto.RasterLayer");
pRasterLayer.CreateFromDataset(pRasterDataset);
pMapServerObjects2 = (IMapServerObjects2)pMapServerContext.ServerObject;
pMapServer = (IMapServer2)pMapServerObjects2;
pMapServerObjects2.get_Map(pMapServer.DefaultMapName).ClearLayers();
pMap = pMapServerObjects2.get_Map(pMapServer.DefaultMapName);
pMap.AddLayer(pRasterLayer);
pMap.AreaOfInterest = pRasterLayer.AreaOfInterest;
pMapServerObjects2.RefreshServerObjects();
}