Some SharePoint objects needs an instance to work perfectly, and below line of code will not work:-
SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
web.RootFolder.WelcomePage=”SitePages/Dashboard.aspx”;
web.RootFolder.Update();
After trying hard came to know that with above way we cannot set the Welcome page for a non-publishing site. Exact reason is not well kept in any MSDN and to set we need to use the SPFolder Object. Below is the sample code of it,
SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
SPFolder folder = web.RootFolder;
folder.WelcomePage = "SitePages/Dashboard.aspx";
folder.Update();
Will post you if I get any..:-)
SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
web.RootFolder.WelcomePage=”SitePages/Dashboard.aspx”;
web.RootFolder.Update();
After trying hard came to know that with above way we cannot set the Welcome page for a non-publishing site. Exact reason is not well kept in any MSDN and to set we need to use the SPFolder Object. Below is the sample code of it,
SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
SPFolder folder = web.RootFolder;
folder.WelcomePage = "SitePages/Dashboard.aspx";
folder.Update();
Will post you if I get any..:-)