Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,
Progrom doing upload excle file from asp.net application to sharepoint server. when i am running application on remote server visual studio 2010. its throw error -:

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.


Code given below -:

C#
string url = "http://ABRLMOREMOSS/";

           using (SPSite siteCollection = new SPSite(url))
           {
               using (SPWeb spWeb = siteCollection.OpenWeb())
               {
                   SPList spList = spWeb.GetList(url);

                   string fileName = "XXXX";
                   FileStream fileStream = null;
                   Byte[] fileContent = null;

                   try
                   {
                       string docPath =Server.MapPath("~/Excel/") + "Report2_Suppliers_OU_Invoice_DATE_HM_15_Dec_2012_1.xlsx"; //physical location of the file
                       fileStream = File.OpenRead(docPath);
                       fileContent = new byte[Convert.ToInt32(fileStream.Length)];
                       fileStream.Read(fileContent, 0, Convert.ToInt32(fileStream.Length));
                       spList.RootFolder.Files.Add(spList.RootFolder.Url + "/" + fileName, fileContent, true);
                       spList.Update();
                   }
                   catch (Exception ex)
                   {

                   }
                   finally
                   {
                       if (fileStream != null)
                       {
                           fileStream.Close();
                       }
                   }
               }
           }
Posted
Updated 17-Dec-12 2:24am
v2
Comments
AnandSharmaUK 21-Feb-13 7:35am    
Are you running the code on the same server i.e., http://ABRLMOREMOSS ? Or you are trying to run the code from a different server pointing to http://ABRLMOREMOSS ? I think if you do the later, you can get this error, so can you confirm this please?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900