The security validation for this page is invalid. RRS feed

  • Question

  • I'm having a horrible time trying to upload a simple file to my SharePoint server.

    I have an ASP.NET MVC4 Web Application running on a Kerberos delegation enabled server.  I am able to query the SharePoint server just fine, but when I attempt to upload a file I get "The security validation for this page is invalid".  All my web searches have returned results suggesting to add the the FormDigest control ... unfortunately I am unable to do that as this is an MVC application and not a webforms application.  Any help here would be greatly appreciated!

    using (var context = this.CreateClientContext())
                        foreach (var library in model.SelectedLibraries)
                            var documents = context.Web.Lists.GetByTitle(library);
                            foreach (HttpPostedFileBase file in model.Files)
                                using (var stream = new MemoryStream())
                                    await file.InputStream.CopyToAsync(stream);
                                    var info = new SharePoint.FileCreationInformation()
                                        Url = Path.GetFileName(file.FileName),
                                        Content = stream.ToArray(),
                                        Overwrite = true,
                                    // upload file to server
                                    var upload = documents.RootFolder.Files.Add(info);

    Wednesday, March 11, 2015 1:03 AM

All replies

  • This could be because the authentication information is not set in the code.  Try setting ClientContext.Credentials ( and check if that helps.

    These postings are provided "AS IS" with no warranties, and confers no rights.

    Wednesday, March 11, 2015 1:48 AM
  • ClientContext.Credentials is set to CredentialCache.DefaultNetworkCredentials.
    Wednesday, March 11, 2015 5:21 AM