tags:

views:

51

answers:

1

I have a custom site definition and in the provisioning handler I am using SPWeb.ApplyWebTemplate("My site defintion name") to apply the site definition. It works fine but i have observed that there is some delay in applying the web template.

What i did is that in the onet of my site defintion i have set the masterurl attribute to /_catalogs/masterpage/MyMaster.master. Now if i create a site under sites folder using this site definition, the sites gest create successfully but on browsing it throws the error as "resource cannot be found". I did some investigation and came to know that the master url should be server relative and not the site relative. So in the provisioning code after applying the template i write the code to update the master URL by prepending Site's server relative URL to it.

Web.MasterUrl = Site.ServerRelativeUrl + Web.MasterUrl;

But when i browse the site it did not work and i got the same error. I debugged the code and found that the even after applying the template the master URL is set to default.master. I waited there on that statement in the debug mode and found that after some time (some secs) the master URL changed to the URL which i set in the onet i.e MyMaster.master.

So looks like ApplyWebTemplate() is an asynchronous method. How can I be assure that the applying web template process is finished.

Thanks.

A: 

You could try getting a new spWeb object for the site after the call and check the Template property.

Nat