0

When I create master page for my web application. after deployed the solution the site showing "Fine Not Found" error.. This is What i have done to create the master page. 1. Created web application in SPCA, 2. In Visual studio i added module and rename the sample.txt to customname.master, 3. Then i copied all code from V4 file paste into my customname.master file. 4. Changes in Element.xml is

          <Module Name="MobileSales" List="116" Url="_catalogs/masterpage">
          <File Path="MobileSales\MobileSales.master" Url="MobileSales/MobileSales.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE"/>
          </Module> 
  1. Changes in Feature is

      public override void FeatureActivated(SPFeatureReceiverProperties properties)
       {
        //SPSite curSite = properties.Feature.Parent as SPSite;
        //SPWeb curWeb = curSite.RootWeb;
        SPWeb curWeb = (SPWeb)properties.Feature.Parent;
        Uri masterUri = new Uri(curWeb.Url +   "/_catalogs/masterpage/MobileSales.master");
        curWeb.MasterUrl = masterUri.AbsolutePath;
        curWeb.CustomMasterUrl = masterUri.AbsolutePath;
        curWeb.Update();
    } 
    
  2. Deployed the solution.

Then i got the error "file not found.. Please help.. i am new to SP.. Please tell me how to create master page in SharePoint 2010 with out using SharePoint Designer. Thank you

2

There might be multiple causes for this error, here are some to check:

  • Make sure you published the master page
  • Make sure to take into account the actual Managed path - "/" vs. deeper managed path, e.g. "/sites/" and construct it accordingly when you change the master page programatically.
  • do make sure it your master page is actually physically deployed in the _catalogs/masterpage document library - seems like in your code, but ensure this via SharePoint 2010 Designer to validate
  • in your code, make sure that SPWeb retrieved from Parent is actually not null (i assume here your feature is site collection scoped - if not please do change as such)
  • I fear your feature states to deploy it physically in a sub-folder called "MobileSales" where as your code to change the master page is actually loading from root of the master page library. - i also suspect this to be the culprit
1

Check out that: The property "Url" of the elements.xml is pointing to "MobileSales/MobileSales.master".

 <Module Name="MobileSales" List="116" Url="_catalogs/masterpage">
      <File Path="MobileSales\MobileSales.master" Url="MobileSales/MobileSales.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE"/>
      </Module> 

So when activated, there will be a "MobileSales" folder on your _catalog/masterpage/ library.
On your code, your target is "/_catalogs/masterpage/MobileSales.master".
You should replace one or another.
Cheers.

  • This is certainly the problem, good catch :) – Robert Lindgren Feb 27 '14 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.