Is there a way to load a different master page if I can identify the user to be annonymous?
|
|
If you want to do it at page level, you can assign a different master page on "OnPreInit" event. Below is the example to do it on layout page if you have publishing site :
If you have many pages, I would recommend to use HttpModule to hook PreInit handler into the page. Below is the example :
|
|||
|
|
|
If your goal is to have a different look and feel for different users, you can use a single Master Page, and include steps that only target specific profiles (anonymous users in your case). Search the internet for the following terms: SPSecurityTrimmedControl and AnonymousTemplate. It is what I use on this draft page: http://usermanagedsolutions.com For authenticated users, the site is just an out of the box SharePoint 2010 page. I add a css layer for anonymous users to modify the page width and hide the top bar. |
|||
|
|
|
This post describes how can you change masterpage dynamiccally. |
|||||||||||
|
|
You can use two options only for targeting content to users (not change of master page):
|
|||
|
|
|
You can include within the Master Page steps that only target specific profiles (anonymous users in your case). Search the internet for the following terms: SPSecurityTrimmedControl and AnonymousTemplate. It is what I use on this draft page: http://usermanagedsolutions.com For authenticated users, the site is just an out of the box SharePoint 2010 page. I add a css layer for anonymous users to modify the page width and hide the top bar. |
|||
|
|
|
This is the same what you asked, See the answer: A seperate masterpage for annoymous users? You can do with httpmodule or a code-behind in a page |
|||
|
|
|
I have tried your example in my publishing site for web part pages. But its not work. i debug the code but event handler is not call the below method. void page_PreInit(object sender, EventArgs e) Please advice... Thanks in advance |
|||
|
