This small article is about a SharePoint caveat that I encountered while developing a WebPart. The cause of the problem was the command:
This indirectly breaks SharePoint and results in an HTTP 404 error.
The Steps to Reproduce
Step 1: Using VS 2007, create a WebPart with the following code:
protected override void CreateChildControls()
Label label = new Label();
label.Text = "Dropzone created";
Also add the code...
... to the AssemblyInfo.cs file.
Step 2: Deploy the WebPart to your SharePoint server. I won't attempt to document the deployment steps because it will take the focus away from the specific topic of this article.
Step 3: Change the trust level of SharePoint from minimal to full. This is not recommended in general, but I only want to show a quick way to allow the WebPart to create a folder.
<trust level="WSS_Minimal" originUrl="" />
<trust level="Full" originUrl="" />
Step 4: Go to YourSite > Web Part Gallery and add the new WebPart. This step may not be necessary for some deployment methods.
Step 5: Go to YourSite > Site Settings > Sites and Workspaces and create a new site for this test.
Step 6: Edit the default page, http://yourserver:###/TestMapPath/Pages/default.aspx, of the new site and add your WebPart to this page. Exit edit mode.
Now whenever you view this page and WebPart, the following folder will be created:
Great, you think. The WebPart worked as expected. It did work as expected, so far. But wait, there is more.
Step 7: Now restart the site. You can easily do this by modifying and saving the \\yourserver\c$\Inetpub\wwwroot\wss\VirtualDirectories\###\web.config file.
Step 8: Now try to visit the page http://yourserver:###/TestMapPath/Pages/default.aspx again.
The site is broken!
When the WebPart created the directory, it created a physical folder that conflicts with the virtual content of the
TestMapPath site. When we accessed the page (after the restart), IIS was looking for the page in the physical folder, and could not find it there. IIS was not able to pass the request down the chain to the SharePoint service and retrieve the virtual content of the page.
- Version 1 dated 22 July 2008