Sharepoint Notes

MOSS: Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
ERROR : The Web Application http://XXX at could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Solution

Assign the application pool of the application which shoots ups this error message, to the pplication pool of MOSS
and use this one also

SPSecurity.RunWithElevatedPrivileges(delegate() {

                    //ur code here
                });
———————–
  public static bool AddAttachment(DateTime date, string caserefId, string fileName, byte[] filebytes, string userId, string taskName, string description) {
                string datefolder = SPLib.getDateFolderName(date);
                SPWeb web = null;
                Hashtable htMetaData = new Hashtable();
                htMetaData.Add(“UploadedBy”, userId);
                htMetaData.Add(“TaskName”, taskName);
                htMetaData.Add(“Description”, description);
                try {
                    SPSecurity.RunWithElevatedPrivileges(delegate() {
                        web = SPLib.getSPWeb();
                        web.AllowUnsafeUpdates = true;
                        //SPList docList = web.Lists[KyELib.KyESettings[“Lists”][“KPMG”][“Name”].Value];
                       
                    });

                    SPList docList = web.Lists[“TestDoc1”];
                    string url = docList.RootFolder.ServerRelativeUrl.ToString();
                    SPFolder folder = web.GetFolder(url + ‘/’ + datefolder);
                    if (folder.Exists) {
                        //folder.Files[i].Item[“Description”] = description;
                        url += @”/” + datefolder;
                        folder = web.GetFolder(url + “/” + caserefId);
                        if (folder.Exists) {

                            //SPListItem item = web.GetList(url + “/” + caserefId).G;
                            //        string name = item[“Name”].ToString();
                            //        item[“Data Status”] = “Completed”;

                            //docList.Fields[“Description”].Title = description;
                            //docList.Fields[“Description”].Update();
                            //docList[“Description”] = description;
                            //site.Fields[“Opened”].Update();
                            //            site.Update();
                            //            SPWeb othersite = site.Site.OpenWeb(“customers/external”);
                            //            othersite.Lists[“Knowledge Base”].ContentTypesEnabled = true; // change here
                            //            othersite.Lists[“Knowledge Base”].Fields.Add(site.Fields.GetField(“Opened”));

                            SPFile fileObj = folder.Files.Add(fileName, filebytes, htMetaData, true);
                            SPListItem listItm = fileObj.Item;

                            listItm[“Description”] = description;
                            //folder.Item[“Description”] = description;
                            //docList.ContentTypesEnabled = true;
                            listItm.Update();
                            fileObj.Update();

                            fileObj.CheckOutStatus = SPFile.SPCheckOutStatus.None;

                           
                            //docList.Update();
                        }
                    }

                    return true;
                } finally {
                    SPLib.closeSPWeb(web);
                }
            }
         

———
In document library

operation is not valid due to the current state of the object

folders should not be inside this  SPSecurity.RunWithElevatedPrivileges(delegate() 

———————

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: