Is there any way to take a screenshot with ASP.net C#, or can we take screenshot of any URL?
Asp.net runs on the web server so there is not way to take a screen shot of the client.
you should use java script and perhaps an ActiveX control to achieve that.
I would not recommend you to go down this road anyway
what you can it to store the content of the page (if this can help) doing something like the below
WebClient client = new WebClient();
string downloadString = client.DownloadString("http://www.gooogle.com");
You can then create and .html file which will look like that page
Related
Is there any way in C# to open a browser using a link and save the loaded html page ?? Actually i don't want to inform server that i am using any software or script .
Actually I want data from this link : http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=120840650200&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=10363
if I try to download the page using webclient it send me another page not the original one.
when i load the previous url in a browser it is redirected to this link:
http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&rt=nc&item=120840650200&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=10363 which is the original page I want to download
so I just wanted to open the browser using the url and save the loaded page.
Thanks in advance
Do you really need to open the browser, or is just (inconspicuously) retrieving the file enough? If so, you can use System.Net.Webclient or System.Net.HttpWebRequest/HttpWebResponse. The former option is much easier, but the latter will allow you to set your own user-agent string to one that would match that of common web browsers.
Straight from MSDN
WebClient client = new WebClient();
Byte[] pageData = client.DownloadData("http://www.contoso.com");
string pageHtml = Encoding.ASCII.GetString(pageData);
Console.WriteLine(pageHtml);
Hi
I'm trying to write a windows application which can read HTML content of a specific website and fill some data in some input fields and submit the page.
what I did untill now was reading page content from a WebBrowser object, navigated to the website.
I know that i need to create some request/response variables and work with them, but I have no good view on what i'm trying to do.
also, my information about HttpRequest and HttpResponse is so low...
HttpWebRequest is what you're looking for, examples for read/write to scrape abound.
WebClient might be simpler for you to implement but in the end is only a wrapper to the above.
You can try to use the approach described in the HttpWebRequest with https in C# thread as a starting point.
I've application that uses another web sites data so how can i get it because it uses some JavaScript functions to get that data and it not show in page view-source.
Check the NET tab in firebug, XHR and check the resource that is requested, and request the same resource.
Basically you have to render the webpage and ensure the javascript functions are run (evaluated). You could do this by "borrowing" their javascript files (by linking to them from your own page), but this may not work as you don't know what's in those files - they could be accessing DOM elements that you don't have in your page, or calling to other domains which may prevent them from working correctly.
The easiest way to show the same data is to just host the page inside an iframe on your own page. If you are looking to do this from a normal client application (i.e. not a web app) then you will need a browser control that you navigate to the target page. If the browser control is invisible you could then scrape values from it and show them in your app, although this is a very clumsy way to do it, and it's debatable about how ethical it is.
If you want the another web site view source use the HTTPWebRequest to get the response stream in c#.
In side a Silverlight Page, I want to redirect to another aspx page in the same web site and using POST method to send some additional header information. Any ideas how to implement this? Any samples are appreciated. :-)
I am using VSTS2008 + .Net 3.5 + Silverlight 2.0 + C#.
My suggestion would be to have a Visibility=hidden Button on the page, and then use javascript to retrieve it and .Click() it. Thus you get to do a post without all the work that this guy went through:
http://mentaljetsam.wordpress.com/2008/06/02/using-javascript-to-post-data-between-pages/
Especially considering it's a bear to craft a POST-to-ASP.NET through javascript, as ASP.NET requires pesky things like viewstate etc.
I think you're looking for HtmlPage.Document.Submit() .
Can Silverlight initiate Page Refreshes?
How do I take an image from an url and save it locally?
http://someurl.com/imagename.jpg
-> c:\apppath\imgfolder
ASP.NET C#
I am not very good with IO stuff, hope someone can help me out :)
Try this.
System.Net.WebClient wc = new System.Net.WebClient();
wc.DownloadFile("http://www.domin.com/picture.jpg", #"C:\Temp\picture.jpg");
Since you've tagged this with ASP.NET, it's worth pointing out that if you put this code in your ASP.NET Website/Web Application, you'll need to make sure the the Identity/Account that your application is running as, has permission to write the file to the file system.