How can I programmatically DELETE the person.aspx page in My Sites?
-
16-10-2019 - |
Question
I want to REPLACE the person.aspx page in the OOTB My Sites Host portal in SharePoint 2010
It works perfectly fine if:
Case 1:
- I open My Sites using SharePoint Designer 2010
- DELETE the person.aspx file under 'All Files'
- Deploy a Solution/Feature with a Module component that provisions a new person.aspx file with the changes I require
OR
Case 2:
I 'Deploy' my project with the same Feature and Module component using Visual Studio 2010, because VS 2010 detects a conflict and this effectively runs a 'DELETE' on the existing person.aspx file
HOWEVER
If I deploy the exact same thing using the wsp package and Central Administration, it no longer works, because it's not able to 'delete' the existing person.aspx in order to provision my new person.aspx file.
Can someone please help?
What is the magic code that SP Designer and VS 2010 run to be able to delete this file??
Solution
You could try adding a Feature Receiver (on FeatureActivated) to delete the existing page, but this will only run after your file gets provisioned. To get around this, you could create 2 features, one visible, one hidden. The visible feature has an ActivationDependency on the second hidden feature which means the hidden feature will get activated automatically first when you activate the visible feature (see http://msdn.microsoft.com/en-us/library/aa543162.aspx) - you can use this to remove the file using a Feature Receiver as mentioned. I would then expect the visible feature to activate afterwards. Try it, but I think it might work for you.