Read xml using WebRequest RRS feed

  • Question

  • There is a XML (a ASPX page that constructs a XML string  with internal sharepoint lists information) published into Sharepoint and securized by him.

    I'm trying to read the ASPX using :



          Dim req As HttpWebRequest = WebRequest.Create(txtURL.Text)
          Dim cred As New System.Net.NetworkCredential("userWithoutDomain", "plainPassword")
          req.Credentials = cred
          Dim response As WebResponse = req.GetResponse()


    But I'm getting 403 forbidden error. How I can connect to this site, pass network or form credentials and read the aspx(XML).?

    I have to read into another sharpoint site and from an externar application.




    Thursday, March 10, 2011 1:41 PM

All replies

  • Thursday, March 10, 2011 2:02 PM
  • It's Similar, but my problem is related to the authentification process.



    Thursday, March 10, 2011 2:41 PM
  • Hi Rodrigo Olivares,

    For your issue, here is an sample code on how to use WebRequest object for your reference.

    WebRequest wr = WebRequest.Create("http://porter:1130/Picture/WebPartPictures/DateInfo.txt");

                wr.Credentials = CredentialCache.DefaultCredentials;

                wr.Method = "PUT";

                using (Stream stream = wr.GetRequestStream())


                    using (StreamWriter writer = new StreamWriter(stream))







                WebResponse response = wr.GetResponse();



    Porter Wang

    • Marked as answer by KeFang Chen Thursday, March 17, 2011 6:05 AM
    • Unmarked as answer by Rodrigo Olivares Thursday, March 17, 2011 12:31 PM
    • Proposed as answer by KEV. CE Wednesday, December 5, 2012 12:43 PM
    Monday, March 14, 2011 1:26 AM