Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Programmatically change zone of the alternate access url in sharepoint2010

$
0
0

 In my application programmatically i need to change the zone of alternate access mapping url

i am able to get alternate access mapping url of webapplication but not able to change zone,i getting an error "Property or indexer 'Microsoft.SharePoint.Administration.SPAlternateUrl.UrlZone' cannot be assigned to -- it is read only"

below is code i tried till now:

 SPWebApplication owebapp = SPContext.Current.Site.WebApplication;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
            foreach (SPAlternateUrl altUrl in owebapp.AlternateUrls)
            {
                if (altUrl.UrlZone == SPUrlZone.Default)
                {
                    //altUrl.UrlZone = SPUrlZone.Internet;
                 //owebapp.Update();
                    string incomingURL = altUrl.IncomingUrl;                  
                  string  publicurl = SPUtility.AlternateServerUrlFromHttpRequestUrl(altUrl.Uri).AbsoluteUri;
                }
            } 
            });

  I searched in net but didn't find any solution,

Please do let me know if any way i can update Alternate access mapping zone.

Note : i know we can do it using power shell , but i need to do using c#  code.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>