I am using the following code to fetch html source website.
private string Extract_Source(string url)
{
string output = "";
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
System.IO.StreamReader r = new System.IO.StreamReader(res.GetResponseStream());
output = r.ReadToEnd();
r.Close();
res.Close();
return output;
}
It can fetch source properly but the problem is it fetch website source based on server from where script executed (i mean where website hosted), but i want to fetch content based on client information (ip etc)
Is it possible in asp.net, if yes can any one help me.
No, it’s not possible to exactly replicate a request from the client from the server, assuming the client is likely to be in a different location.
On the server side, you can get close by copying headers from the clients request (user agent etc.) to the request you’re constructing, but this won’t make the server side request appear to originate from the clients IP.
If you can use AJAX (i.e. the URL you are accessing is on the same domain) then you could have the client retrieve the HTML from the URL via AJAX and then post it from the client to the server with an AJAX request.