Hello,
I created a custom control that is embedded on the MySite private view
(.C:\Program Files\Common Files\Microsoft Shared\web server
extensions\60\TEMPLATE\1033\SPSMSITE) executes the code to add
webparts. The control just executes some code, reads a xml config file
in which the onet.xml like config is stored.
Everything works fine, but I can not add the webpart using the
following code:
SPSite site=SPControl.GetContextSite(Context);
SPWeb web=SPControl.GetContextWeb(Context);
SPFile file=web.Files["default.aspx"];
site.AllowUnsafeUpdates=true;
web.AllowUnsafeUpdates=true;
SPWebPartCollection col=file.GetWebPartCollection(Storage.Personal);
System.Guid wpGuid=col.Add(webpart.InnerXml);
The last line results in the error:
Server Error in '/MySite' Application.
--------------------------------------------------------------------------- -----
Updates are currently disallowed on GET requests. To allow updates on a
GET, set the 'AllowUnsafeUpdates' property on SPWeb.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Updates
are currently disallowed on GET requests. To allow updates on a GET,
set the 'AllowUnsafeUpdates' property on SPWeb.
The default.aspx has already a form digest embedded:
...
<body marginwidth="0" marginheight="0" scroll="yes"
spsid="SitePageTemplate" id="PageBody" runat="server">
<form runat="server">
<SharePoint:FormDigest runat="server" id="FormDigest1" />
...
Any ideas? I do not know how to avoid being a get request in my page
because the control code should run if the user gets his private view.
I can avoid the error using a artificial post but I can not use a post
for production.
Thanks a lot for hints!!
Michael