Tech Battle Field

Wednesday, July 26, 2006

The security validation for this page is invalid. Click Back in your Web

If you are getting the following error, while renaming the page title using publishingpage object
"The security validation for this page is invalid. Click Back in your Webbrowser, refresh the page, and try your operation again."

Code Snippet:

PublishingWeb publishingweb = PublishingWeb.GetPublishingWeb(newUri("http://YourPortal/Plans/"));
PublishingPage pp =publishingweb.GetPublishingPages()["Pages/TestArticle.aspx"];

pp.Title = e.Node.Text;
pp.Update();

You should check for this :

Navigate thru the followwing and turn the security validation Off

Central Administration--->application management---->web application settings-->"turn security validation off"



27 Comments:

  • Thanks man, i've been trying for this from 3 days...

    By Anonymous Anonymous, at 12:54 AM  

  • thanks,

    i've been searching for this from 2 days....

    By Anonymous Anonymous, at 12:54 AM  

  • This is dangerous to do....could potentially leave your site open to malicious code..ideally, the security validation should be turned off only long enough for your own code to execute and should be turned back on again as soon as the code finishes execution.
    So,
    web.AllowUnsafeUpdates=true;
    [your update code]
    web.AllowUnsafeUpdates=false;

    By Anonymous Anonymous, at 1:06 PM  

  • Talk about a PITA - Pain in the ass. Where in the hell did this idea come from? I can think of 10 different ways to implement this without causing such a damn headache... Madness.

    By Blogger Thomas, at 4:03 PM  

  • I am changing security on the document library folder.

    I tried following things

    1) Impersonation
    2) web.AllowUnsafeUpdtes = true;

    It did not work. I tried what is suggested in this post and it worked. I know this might not be the right way of doing it but then where is the solution?

    By Anonymous Anonymous, at 10:05 AM  

  • Haleluja!!! Finaly!

    By Anonymous Anonymous, at 2:38 AM  

  • I didn't actually test this with a PublishingWeb but I was getting a similar error when adding personal views using an "impersonated" site. Turning off security validation as described in this post worked for me too. I was also able to turn validation off and on programmatically through an SPWebApplication object:

    SPWebApplication webApp = web.Site.WebApplication;
    webApp.FormDigestSettings.Enabled = false;

    ...Run code...

    webApp.FormDigestSettings.Enabled = true;

    By Anonymous Anonymous, at 11:50 AM  

  • The last anonymous poster's suggestion solved my problem. I had been attempting to modify the quota information for individual site collections. Changing AllowUnsafeUpdates on SPSite and SPWeb objects never worked for me, nor did attempting to include a <SharePoint:FormDigest> within my form since my app is hosted outside of SharePoint. Temporarily turning off FormDigest programmatically at the web application level solved my security validation issue. Thanks anonymous, I had been searching for an answer to this one for a while.

    By Anonymous Anonymous, at 9:54 AM  

  • There are two:
    Site.AllowUnsafeUpdates=true
    Web.AllowUnsafeUpdates=true

    Web doesn't do it. Site does.

    By Anonymous Anonymous, at 4:03 PM  

  • This did the trick.

    SPWebApplication webApp = web.Site.WebApplication;
    webApp.FormDigestSettings.Enabled = false;

    Thanks Anonymous

    By Anonymous Anonymous, at 12:13 PM  

  • Thanks a lot.. this article helped me a lot and also not to forget the comments at the bottom.

    By Anonymous Kaushik, at 6:19 AM  

  • Anonymous, YOU're the man!!!

    By Anonymous Anonymous, at 8:47 AM  

  • my problem was different... it involve using the code below

    using(SPSite site = new SPSite(strDashListRoot))
    {
    using (SPWeb web = site.OpenWeb())
    {
    web.AllowUnsafeUpdates = true;

    SPList list = web.Lists["Tasks"];
    SPListItem Item = list.Items.Add();
    Item["Title"] = "from web app";
    //Item["DateReceived"] = System.DateTime.Now;
    //Item["Description"] = txtDescription.Text;
    Item.Update();

    web.AllowUnsafeUpdates = false;
    }
    }


    setting the allowunsafeupdates property worked for me...

    By Anonymous Anonymous, at 4:35 AM  

  • Great .......What are the risks we will be having coz of this.........

    By Anonymous Ashish, at 3:30 AM  

  • Great!!saved lots of time "turn off validation" worked in my case.

    By Anonymous Anonymous, at 4:55 AM  

  • The web.AllowUnsafeUpdates=true is working.
    I had this code working and suddenly got this odd exception.
    I tracked any code changes I've made and found out I accidently placed the flag set line, after the AddWebPart. Took me 3 hours to discover that !

    By Blogger Asaf Mesika, at 4:44 AM  

  • Thanks for your article. It's a great help.

    I am trying to update one field in my list via a .net application. When it gets to the listitem.update(), i get the dreaded "The security validation for this page is invalid", even though the logon I am using is the site administrator. When i show spweb.currentuser, it shows the correct user and .issiteadmin = true.

    I must be missing something.

    Any ideas? Thanks.

    By Blogger Susiew32, at 6:37 AM  

  • This did it for me:

    Using site As New SPSite(applicationURL)
    Using web As SPWeb = site.OpenWeb()
    Dim projectSite As SPWeb = web.Webs(siteName)

    projectSite.AllowUnsafeUpdates = True

    Dim wa As Administration.SPWebApplication
    wa = site.WebApplication
    wa.FormDigestSettings.Enabled = False


    Turn off the Security validation from the Administration > Operations WAS not Required

    By Blogger Danko Greiner, at 5:40 AM  

  • Thank you so much !

    By Anonymous Anonymous, at 7:36 AM  

  • Thanks guys. Very kind of you ! I have been trying for days....

    *SAP*

    By Anonymous Anonymous, at 2:11 PM  

  • welcome to the wow power leveling cheap Wow gold service site, buy cheap wow gold,wow gold,world of warcraft power leveling buy wow gold

    By Blogger dghnfgj, at 11:15 PM  

  • thanks dude.. saved my time.

    By Blogger Raghavendra K, at 10:35 PM  

  • Thanks .....It worked for me.

    By Anonymous Anonymous, at 12:03 AM  

  • Weaknesses of World Of Warcraft Gold the client-server model used by World of Warcraft have been wow power levelingexploited in order to crash the cluster of servers that aoc goldmake up a realm. Exploits also include characters being able to instantly Cheapest Wow Goldchange location or teleport. The situationbecame worse cheap wow goldwhen trying to coordinate activities across a number of playersor guilds on the same realm.World of Warcraft Lead Producer, stated that new realms would be introduced to warhammer goldrelieve the burden on existing ones. Existing realms would be upgraded.

    Although the game wow gold follows a similar model to others in the genreand was noted for having wow gold cheapmany familiar concepts from roleplaying games, the new approaches gold4powerto reduce pauses between game encounters was well liked. At various times, World of Warcraft players have experienced problems with connecting to and logging in to wow gold for sale the game. Sudden server crashes that would force realms offline also occurred.

    By Anonymous world of warcraft gold, at 9:42 PM  

  • Thanks very much SpiderWool really you saved me with your post and Thanks Thanks Anonymous I Tried your suggest
    web.AllowUnsafeUpdates=true;
    [your update code]
    web.AllowUnsafeUpdates=false;

    and it works well

    By Anonymous Anonymous, at 7:29 AM  

  • Thank you thank you thank you Anonymous! I have to use ListItem.BreakRoleInheritance(false) and reset permissions on a list item and "AllowUnsafeUpdates" did not work. This worked!

    Thanks,
    Steve

    By Anonymous Anonymous, at 8:02 AM  

  • Thanks a lot. I've been searching for this from 3 days...

    By Anonymous Anonymous, at 6:01 AM  

Post a Comment

<< Home