none
Updates are currently disallowed on GET requests

    Soru

  • Hi, 

    i am trying to create a custom ECB item menu to run a VS2010 workflow. When I click on the ECB item menu and error throws:

    Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.

    I have tried to add a spweb.AllowUnsafeUpdates = true; in the code, but no luck. :[

    Any one can help????????

    SPList list = Web.Lists[new Guid(Request.QueryString["ListId"])];
                SPListItem item = list.GetItemById(int.Parse(Request.QueryString["ItemId"]));
    
                try
                {
                    using (SPSite site = SPContext.Current.Site)
                    {
                             Guid GUID = new Guid("{D432D2A3-A908-4ADA-80F1-FDDF34DA3373}");
                        SPWorkflowAssociation associationTemplate = list.WorkflowAssociations[GUID];
                        SPWorkflowManager manager = site.WorkflowManager;
    
                        manager.StartWorkflow(item, associationTemplate, associationTemplate.AssociationData);
                        Response.Redirect(Web.Url + "/Lists/JobList/AllItems.aspx");
                    }
                    
                }
                catch (Exception ex)
                {
                    Response.Redirect("/_layouts/Error.aspx?ErrorText=" + Server.UrlEncode(ex.Message));
                }

    15 Haziran 2012 Cuma 10:23

Yanıtlar

  • Hello,

    I see you have two open contexts and are mixing them. Could you ensure that the item is in the correct site you allowed unsafe updates?

    Also, to access parent site collection you can use Site property on SPWeb object, e.g. web.Site.WorkflowManager.StartWorkflow(...);


    Please don't forget to mark the post as Helpful if you find my comment useful and as Answer if it solved your problem.
    INFOTEHNA Group, Document and Process Management Solutions ( www.infotehna.com )

    • Yanıt Olarak İşaretleyen karen0123456789 16 Haziran 2012 Cumartesi 02:35
    15 Haziran 2012 Cuma 11:23

Tüm Yanıtlar

  • Hello,

    I see you have two open contexts and are mixing them. Could you ensure that the item is in the correct site you allowed unsafe updates?

    Also, to access parent site collection you can use Site property on SPWeb object, e.g. web.Site.WorkflowManager.StartWorkflow(...);


    Please don't forget to mark the post as Helpful if you find my comment useful and as Answer if it solved your problem.
    INFOTEHNA Group, Document and Process Management Solutions ( www.infotehna.com )

    • Yanıt Olarak İşaretleyen karen0123456789 16 Haziran 2012 Cumartesi 02:35
    15 Haziran 2012 Cuma 11:23
  • Hi,

    Please check this link here.

    Just as a side note - you don't need to use the using statement when accessing SPSite (or any other object) through SPContext.

    Cheers,

    Dan.


    You can find my blog here: http://developertrack.blogspot.com

    15 Haziran 2012 Cuma 11:30
  • Thanks for reply. 

    I changed the code to this, and the error disappear. However, the page process for long and stuck at the line manager.StartWorkflow. :[

    SPList list = Web.Lists[new Guid(Request.QueryString["ListId"])];
                SPListItem item = list.GetItemById(int.Parse(Request.QueryString["ItemId"]));
    
                try
                {
                             Web.AllowUnsafeUpdates = true;
                             Web.Update();
                             Guid GUID = new Guid("{D432D2A3-A908-4ADA-80F1-FDDF34DA3373}");
                        SPWorkflowAssociation associationTemplate = list.WorkflowAssociations[GUID];
                        SPWorkflowManager manager = Web.Site.WorkflowManager;
    
                        manager.StartWorkflow(item, associationTemplate, associationTemplate.AssociationData);
                        Response.Redirect(Web.Url + "/Lists/JobList/AllItems.aspx");
                    
                    
                }
                catch (Exception ex)
                {
                    Response.Redirect("/_layouts/Error.aspx?ErrorText=" + Server.UrlEncode(ex.Message));
                }


    16 Haziran 2012 Cumartesi 02:35