Search code examples
c#phpasp.netasp.net-3.5p3p

Get response from php page


I need to call .php page from my aspx.cs page.but I don't want to load the page.I just want to call the page and the page will give me XLM response that I need to store in DB.I am trying this with the Ajax,but according to this link.We are not be able to call cross domain page from ajax.

In short I want to read the data from php page using asp.net code.

can anybody please help me out.

Update :: Is the P3P policy will usefull in case of cross domain page calling.


Solution

  • I got the solutions,thanks for your help.

    create a new WebClient object

    WebClient client = new WebClient();
    
    string url = "http://testurl.com/test.php";
    

    create a byte array for holding the returned data

    byte[] html = client.DownloadData(url);
    

    use the UTF8Encoding object to convert the byte array into a string

    UTF8Encoding utf = new UTF8Encoding();
    

    get the converted string

    string mystring = utf.GetString(html);