Sharepoint 2010 Forum

 
Home » Forum » Sharepoint 2010       Ask a questionRSS Feeds

"Updates are currently disallowed on GET requests. To allow updates

  Date: Sep 03, 2011      Category: Sharepoint 2010      Views: 224
 

I'm hitting this and having the issue that, despite setting the
AllowUnsafeUpdates property, I'm still getting the error. when the
searchAlert.Update function is called.

Any tips?

using (SPSite site = new SPSite(SPContext.Current.Site.Url))

{

using (SPWeb web = site.OpenWeb())

{

site.AllowUnsafeUpdates = true;

web.AllowUnsafeUpdates = true;

web.Update();

SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)
SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(site));

KeywordQuery query = new KeywordQuery(proxy);

query.ResultsProvider = SearchProvider.Default;

query.QueryText = queryString;

SearchAlert searchAlert = new SearchAlert(site, query);

searchAlert.Update();

}

}

Tagged:                  

 

4 Answers Found

 
Answer #1       Answered On: Sep 03, 2011       

It's been a while, but I believe you can get around this by using a delegate
with RunWithElevatedPrivileges. See if this post helps at all:

blog.bugrapostaci.com/tag/allowunsafeupdates/

 
Answer #2       Answered On: Sep 03, 2011       

I'm afraid that it isn't working (could there be an issue with my code?)

Guid siteId = SPContext.Current.Site.ID;
Guid webId = SPContext.Current.Web.ID;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteId))
{
site.AllowUnsafeUpdates = true;
using (SPWeb web = site.OpenWeb(webId))
{
web.AllowUnsafeUpdates = true;
web.Update();
SearchServiceApplicationProxy proxy =
(SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceC\
ontext.GetContext(site));
KeywordQuery query = new KeywordQuery(proxy);
query.ResultsProvider = SearchProvider.Default;
query.QueryText = queryString;
query.ResultTypes |= ResultType.RelevantResults;
SearchAlert searchAlert = new SearchAlert(site, query);
// Throws exception here
searchAlert.Update();
}
}
});

 
Answer #3       Answered On: Sep 03, 2011       

I think there is no need to put a web.Update().

What is the exceptions ?

 
Answer #4       Answered On: Sep 03, 2011       

There is a hot fix for SP1. http://support.microsoft.com/kb/953138

 


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].