Published Master through Designer showing differently to different users

rajivkapoorONidealsdotcodotin
rajivkapoorONidealsdotcodotin used Ask the Experts™
on
Custom Master page was published for all the site users to change the look of site through SPD but after publishing it shows differently (a little out of place and missing some menu options and menu color...) to some users. Attached are the 3 files:
1st... shows site what I had before the page was published
2nd... shows my view of Master page that was published with the looks intended as site collection administrator
3rd...shows the some user's view of it. (They are those who dont have site collection administrator rights.) 1st image showing--Site View Before publishing for all users 2nd image showing--what I expect to be published for view to all users 3rd image showing--what some users see it as published when they are logged onIt has been also observed that the view of the master page seems to be correct when they are assigned site collector rights but not when they use normal rights as per their assigned role.
If you can help with how to get the view of some of these users who are seeing as published differently so that they can also get the correct view of the site, it will be hightly appreciated.
Thanks alot.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hello,
Usually to publish a new Master Page you need to publish it as a public version (not as a draft) and approve it in the Master Page gallery.
Please try this solution:
Enter your site using a browser, enter the site master pages gallery (http://yoursiteurl/_catalogs/masterpage). Check out your master page file. Check it in again as a primary public version. Then click on this file again and you should see the "Approve/Denied" option. Click on it and approve the file.
I hope it helps.
it looks like your other users may not have permission to your master page.

In ASP.NET terms, we know that the master page shows up for admin users, so we would focus on the other group i.e. authenticated normal users. So, we will change the master page after their user type identification dynamically to point their default master page to what you are publishing for them to use. The approach would involve changing their master page by creating a class which will inherit from the Page class say MyBasePage checking the user’s MasterPageFile in use according to his authentication.
Change MyBasePage’s Page_Pre_Init event to explicitly define his/her MasterPageFile after comparing CurrentUser.UserType with UserType.NormalAuthenticated
So do as follows,
Develop a custom HttpModule by writing a class which will inherit from System.Web.IHttpModule. IHttpModule defining Init and Dispose as below
public class DynamicMasterPageModule : IHttpModule
{
                public void Dispose()
                {
                }
                public void Init(HttpApplication context)
                {
                                context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
                }
                void context_PreRequestHandlerExecute(object sender, EventArgs e)
                {
                                Page page = HttpContext.Current.CurrentHandler as Page;
                                if (page != null) 
                                {
                                                page.PreInit += new EventHandler(page_PreInit);
                                }
                }
                void page_PreInit(object sender, EventArgs e)
                {
                }
}

Open in new window

This way Sharepoint page can also be handled by the event if load request is send by any user
Now, we will refer to your custom Master Page from the Content Page using either dynamic or static tokens according to the token taken by it say dynamically you are setting it to ~masterurl/default.master then you would need to use SPWeb.CustomMasterPageUrl property to set to your custom MP to dynamically change. So, say if you have defined in your web.config the page numbers to use as a criteria to refer to the reqd custom master page dynamically according to the number criteria (for the purpose the criteria can be according to your choice) , you will change master page according to the criteria as below:
void page_PreInit(object sender, EventArgs e)
     {
         Page page = sender as Page;

         string pageNo = ConfigurationManager.AppSettings["MasterPageNo"];

         if (page != null)
         {
             if (pageNo.Equals("1"))
             {
                 page.MasterPageFile = "~masterurl/custom.master";
                 if (SPContext.Current != null)
                 {
                     SPContext.Current.Web.CustomMasterUrl = 
                                                                "/_catalogs/masterpage/custom1.master";
                 }
             }
             else if (pageNo.Equals("2"))
             {
                 page.MasterPageFile = "~masterurl/custom.master";
                 if (SPContext.Current != null)
                 {
                     SPContext.Current.Web.CustomMasterUrl = 
                                                                "/_catalogs/masterpage/custom2.master";
                 }
             }
             else
             {
                 page.MasterPageFile = "~masterurl/default.master";
                 if (SPContext.Current != null)
                 {
                     SPContext.Current.Web.MasterUrl = 
                                                                "/_catalogs/masterpage/default.master";
                 }
             }
         }

Open in new window

Finally, you can comment out the else section as you don’t want then to use their default master.
So, using the class for HttpModule you wrote, you can handle the MP so that the user with normal authentication also uses your custom MP and not any other.
For more info click on "2. How to dynamically change SharePoint custom Master Page" link on Dynamically change SP MP
Local user end publishing of MP should be taken into consideration as the user may screw up his end of default MP

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial