.NET King Logo Comments on: Assigning master page to a SharePoint 2013 site programmatically (Client Side Object Model)
Skip Navigation Links
0 Items in Video cart!

Assigning master page to a SharePoint 2013 site programmatically (Client Side Object Model) (11/3/2015)

As I mentioned in the previous post, I put a simple function together to assign the master page for a SharePoint 2013 website using Client Side Object Model (CSOM). This function can be simply used in a provider hosted App or a simple consol application.


// Client Side Object Model
/// <summary>
This function gets the site Url and master page name and assigns the new master page to the site
<param name="siteUrl">The URL of the site you'd like to change the master page programmatically</param>
<param name="masterPageFileName">The file name of the new master page
void setMasterPageCSOM(string siteUrl, string masterPageFileName)
ClientContext ctx = new ClientContext(siteUrl);
Web rootWeb = ctx.Site.RootWeb;
List masterPageList = rootWeb.Lists.GetByTitle("Master Page Gallery");
File newMasterPage = masterPageList.RootFolder.Files.GetByUrl(masterPageFileName);
    ctx.Load(newMasterPage, mp => mp.ServerRelativeUrl);
Web currentWeb = ctx.Web;
    currentWeb.CustomMasterUrl = newMasterPage.ServerRelativeUrl;
    currentWeb.MasterUrl = newMasterPage.ServerRelativeUrl;

By: Seals  
P.S Мои извинения за отход от тематики,
однако я не могу не спросить!
Не могли бы вы сообщить мне, на каком хостинге
размещен веб-ресурс? Я загрузил ваш блог в 2-х совершенно разных
веб-браузерах, и должен сказать, что он грузится очень быстро.
Можете ли вы предложить качественный веб-хостинг по
приемлемой цене? Заранее спасибо )
URL: http://bps6nastrojkaruletka.cekuj.net  
By: Saiz  
Hey! I know this is sort of off-topic however I
had to ask. Does operating a well-established blog such as yours require a massive amount work?
I am completely new to running a blog however I do write in my journal every day.
I'd like to start a blog so I can easily share
my personal experience and feelings online. Please let
me know if you have any kind of suggestions or tips for brand new aspiring blog
owners. Appreciate it!
URL: http://goo.gl/RcybAC  
By: Leach  
Hi there to all, the contents present at this web page are genuinely amazing for people knowledge, well, keep
up the good work fellows.
URL: http://s.miku.moe/minecraft156954  
By: Jelks  
Excellent blog here! Also your site loads up very fast!
What web host are you using? Can I get your affiliate link to
your host? I wish my site loaded up as fast as yours lol
URL: http://goo.gl/BCKDt7  
By: Lockwood  
I do not know if it's just me or if perhaps everyone else encountering issues
with your blog. It seems like some of the text on your
posts are running off the screen. Can somebody else please provide feedback and let
me know if this is happening to them as well? This may
be a issue with my internet browser because I've had this happen before.
Thank you
URL: http://goo.gl/RcybAC  
By: Franki  
Since the admin of this website is working, no question very quickly it
will be well-known, due to its feature contents.
URL: http://fw.ax/qokf1  
By: Mummery  
I blog often and I seriously thank you for your content.
This great article has truly peaked my interest. I will
bookmark your blog and keep checking for new information about once per week.
I subscribed to your Feed too.
URL: http://stpicks.com/minecraft684318  
By: Whitely  
Hola! I've been following your weblog for a while now and finally got the bravery
to go ahead and give you a shout out from Porter Texas!
Just wanted to mention keep up the good work!
URL: http://www.abcagency.se/minecraft425801  
By: Locke  
Крайне информативный блог, он мне безумно понравился ) Здесь я нашел много нужной информации:) Будет ли вторая часть этой статьи?
URL: http://telegraf.by/2018/05/10/396207-v-harkove-mujchina-s-23-grn-viigral-v-onlain-kazino-164-449-griven  
By: email@gmail.com  
vozYs2 It'а†s actually a great and helpful piece of information. I am happy that you shared this useful info with us. Please stay us up to date like this. Thanks for sharing.
URL: email@gmail.com  
By: Air Jordan 12 Mens  
It is really a nice and helpful piece of info. I glad that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.
URL: http://www.nikeoutlet-storeonlineshopping.com/air-jordan-12-mens-c1_29.html  
By: Nike Lebron 12 Womens  
Hello would you mind stating which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I'm looking for something unique. P.S My apologies for getting off-topic but I had to ask!
URL: http://www.nikeoutlet-storeonlineshopping.com/nike-lebron-12-womens-c17_71.html  
By: Fitflop Flower Sandals  
WONDERFUL Post.thanks for share..extra wait .. ?
URL: http://www.fitflopssaleclearanceuk.com/fitflop-flower-sandals-c5.html  
By: Moncler Outlet UK  
Heya i am for the primary time here. I came across this board and I find It truly helpful & it helped me out a lot. I'm hoping to give something again and help others such as you aided me.
URL: http://www.monclerjacketsonsalevip.cc  
By: Fitflops Sale Clearance  
Thanks for any other wonderful post. The place else could anyone get that kind of information in such an ideal manner of writing? I've a presentation next week, and I'm on the search for such info.
URL: http://www.fitflopssaleclearanceuk.com  
By: 2rand[0,1,1]  
ys5N4E https://www.genericpharmacydrug.com
URL: 2rand[0,1,1]  
By: 2rand[0,1,1]  
Nch2Ts https://www.genericpharmacydrug.com
URL: 2rand[0,1,1]  
By: poe trade currency  
nice going!
URL: http://www.51pay.org/poe-how-to-remove-elder-from-our-atlas-without-beating-him/  
By: where to get cheap nfl jerseys  
In the WordPress support forum, there are from time to time questions abut trackbacks. I haven't used it myself, but I found a good tutorial on the OptiNiche cheap nfl jerseys china blog.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: cheap china jerseys nfl  
Pretty section of content. I just stumbled upon your web site and in accession capital to assert that I acquire in fact enjoyed account we supply cheap nfl jerseys your blog posts. Any way Il be subscribing to your augment and even I achievement you access consistently quickly.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: cheap nfl football jerseys for sale  
Il immediately postcheap nfl jerseys china snatch your rss feed as I can not find your email subscription link or newsletter service. Do you have any? Kindly allow me recognize so that I may subscribe. Thanks.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: 2rand[0,1,1]  
2Wd0cs https://goldentabs.com/
URL: 2rand[0,1,1]  
By: discount nfl jerseys china  
Since I didn't really understand how this works,we supply cheap nfl jerseys I did some searching and found an outstanding WordPress Trackback Tutorial that explains much of what I was finding confusing.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: FFXIV Gil  
How come you are working here?
URL: http://www.cheapguildwars2gold.net/ffxiv-some-other-fun-update-and-the-limitations-of-feature/  
By: Goheen  
reverse phone lookup in germany reverse phone lookup private number reverse phone lookup free no sign up
URL: http://reversephonelookup.bid  
By: buy nba 2k17 mt pc  
You are the savior of my life.
URL: http://forum.thb.vn/yaf_postsm17322_NBA-2K17-Patch-1-05-May-Arriving-Having-Pro-Am-Mend-And-Roster-Changes.aspx  
By: buy Cheap NBA 2K17 MT  
Do you have a good sense of humor .
URL: http://cylindrymiarowe.pl/blogs/25800  
By: Cheap NBA 2K17 MT XBOX ONE  
Why don't we give this a try?
URL: http://www.clubwww1.com/dating/member/blog_post_view.php?postId=58401  
By: Cheap NBA 2K17 MT Coins  
That makes two of us.
URL: http://nba2k17.mywapblog.com/sport-nba-2k17-should-have-cut-throat-eq.xhtml  
By: NBA 2K17 MT  
Today looks great .
URL: http://tmtctata.com/index.php/learning-resources/blogs/entry/nba-2k17-mycareer-badges-and-how-to-get-them.html  
By: nike air force mid  
I carry on listening to the reports lecture about getting free online grant applications so I have been looking around for the finest site to get one. Could you tell me please, where could i get some?
URL: http://www.eumill.it/victory.cfm?fg=id-6380  
By: nikita wikipedia  
I have been reading out many of your articles and it's nice stuff. I will make sure to bookmark your site.
URL: http://www.eumill.it/victory.cfm?fg=id-790  
By: nike free sverige  
My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine just how much time I had spent for this info! Thanks!
URL: http://www.hammarsvens.se/class.asp?bw=id-5016  
By: nike tiempo legend iii  
I just couldn't leave your web site before suggesting that I really loved the standard information a person provide on your guests? Is going to be back often to check out new posts
URL: http://www.vecchiovarzi.it/test/plata.cfm?bw=nike-tiempo-legend-iii  
By: buy birkenstocks  
I truly appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You've made my day! Thank you again
URL: http://www.euromode-eurosped.ie/yari.php?point=id-3635  
By: fifa 17 pc coins  
What is with that guy?
URL: http://www.kirchhertener-hunnen.de/index.php?forum-showposts-24999  
By: u4fifa.com  
i like this site a lot!
URL: http://forums.cozycot.com/forum/lifestyle/entertainment/4670753-fifa-17-address-problems-will-be-soon-fixed  
By: Albion Online Gold  
youre really talented.
URL: https://albiontips.wordpress.com/2016/07/06/six-laws-of-the-jungle-in-albion-pvp-world-%E2%85%A0/  
By: buy viagra  
Hello! I know this is kinda off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having trouble finding one? Thanks a lot!
URL: http://ibuyallvehicles.com  
By: fifa coins  
Im very pleased with your work.
URL: http://patch.com/massachusetts/marthasvineyard/u4fifacom-professional-fifa-coins-seller-0  
By: nike air max 1 femme  
Hi there, after reading this amazing article i am too glad to share my knowledge here with friends.
URL: http://bioresp.eu/files/nike-air-max-1-femme.php  
By: nike air max kaufen  
I have been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all site owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.
URL: http://hroniki34.com/templates/nike-air-max-kaufen.php  
By: oferta zapatillas salomon  
Hello, after reading this awesome paragraph i am too happy to share my familiarity here with friends.
URL: http://www.i-think.es/oferta-zapatillas-salomon.php  
By: christian louboutin outlet  
Definitely, what a magnificent site and enlightening posts, I surely will bookmark your site.Best Regards!
URL: http://www.colegiolamilagrosa.es/mail/christian-louboutin-outlet.asp  
By: buy blade & soul gold  
look great today.
URL: http://audiorealism.se/phpBB2/viewtopic.php?t=2684  
By: cheap adidas inc  
Thanks for some other fantastic post. The place else may just anyone get that type of info in such a perfect manner of writing? I have a presentation next week, and I am on the search for such info.
URL: http://www.meksyk-i-jego-zabytki.cba.pl/mains.php?adidas-1496.html  
By: �����å��� ��ȫѥ  
Well I definitely liked reading it. This post provided by you is very useful for good planning.
URL: http://www.rlvradio.com.ar/mains.php?asics-752.html  
By: �����å��� �ȥå�3  
Wonderful goods from you, man. I have understand your stuff previous to and you are just too great. I actually like what you've acquired here, certainly like what you're saying and the way in which you say it. You make it entertaining and you still care for to keep it sensible. I can't wait to read far more from you. This is actually a wonderful website.
URL: http://www.costaurbana.com.uy/mains.php?asics-381.html  
By: used mulberry bags Outlet  
This video post is actually enormous, the sound feature and the picture quality of this tape post is genuinely awesome.
URL: http://www.cruciblesnookerclub.com/uppe.cfm?no=id-7636  
By: mulberry stockholm rea  
I think this is among the most important information for me. And i'm glad reading your article. But wanna remark on some general things, The web site style is great, the articles is really excellent : D. Good job, cheers
URL: http://www.aloppe.se/onle.asp?hund=id-3266  
By: tommy hilfiger dunjacka dam  
What i don't realize is in fact how you're not actually a lot more well-preferred than you may be right now. You are very intelligent. You know therefore considerably when it comes to this subject, made me personally imagine it from numerous various angles. Its like men and women are not involved except it��s something to do with Lady gaga! Your personal stuffs outstanding. Always take care of it up!
URL: http://www.tekniskabyran.se/polaur.asp?rans=tommy-hilfiger-dunjacka-dam  
Your name: