Add Webpart to MySite from a own control



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

.



Relevant Pages

  • Re: dm-ioband + bio-cgroup benchmarks
    ... I have got excellent results of dm-ioband, that controls the disk I/O ... bandwidth even when it accepts delayed write requests. ... every device we want to control using rules. ...
    (Linux-Kernel)
  • Re: ADO Form bind
    ... I needed this Inconsistant updates so the user can edit the data - however, ... I do not want the data that was updated in a particular control to update the ... I don't believe you can bind an updatable form ...
    (microsoft.public.access.formscoding)
  • Re: Windows XP Service Pack 2
    ... > MS-MVP Windows - Shell/User ... > | will have improved control and reporting of update delivery also. ... > | It sounds to me like you should get comfortable with using GPO ... > |> this apart from the traveling users that now pull their updates across ...
    (microsoft.public.windowsxp.security_admin)
  • Re: dm-ioband + bio-cgroup benchmarks
    ... I have got excellent results of dm-ioband, ... bandwidth even when it accepts delayed write requests. ... This will provide us the control of releasing ...
    (Linux-Kernel)
  • Re: [PATCH 1/9] io-throttle documentation
    ... +the page cache are processed asynchronously by kernel threads (pdflush), ... all the write-back requests that are not directly submitted by ... should be able to provide max bw control at IO scheduler level (along ... scheduler in the elevator, when the IO requests are submitted. ...
    (Linux-Kernel)