C# download web-content after submit - c#

I need to automate the download of a file from this site http://stats.smith.com/reports/Default.aspx?btnGo=View+Report. My problem is once I click on the submit buttom I lose control and a download dialog pops up. Is there a way to download the file using c# and avoid the download dialog? I'm currently using the WebBrowser object in the Forms assembly to navigate through the page.

Take a look at the WebClient class

If you want to save a downloaded file to the filesystem from a web browser, there must be user interaction. A web page does not have permission to muck about in a client's file system.
If you want to display the page in the browser, you can try removing the Content-Disposition=attachment;... server response header when the file is downloaded. This will only work if the client has the browser set to display such file types inside the browser.

Your question doesn't specify what you're using to download the file.
If you're asking if you can have a program that runs on a client (either a WinForms app, a console app, or a Windows Service) then you can download a file from a web site using the System.Net.WebClient class and calling the DownloadFile() method.
The accepted answer here (slightly different than you question, so it's not a duplicate) has a link to show how to download a file that requires an HTTP post first.
If you're trying to somehow automate Internet Explorer via a javascript from a web page you're hosting to force a file to download on a user without displaying the dialog box, then no. You can't.

Related

How to download a file with Selenium when it's imposible to use WebDrivers with GUI?

I need to download a pdf file with Selenium. This pdf file is downloaded when a button is clicked. The URL of the file isn't accesible, the button submit a form and the server response directly with the file (without confirm dialog).
I'm using PhantomJS WebDriver (the project is in C#) because the application will be an Azure webapp, so I can't use ChromeDriver or similar. The problem is that PhantomJS can't deal with binary files, so when I simulate the click in the button the app doesn't download anything.
Any ideas??
P.D: Selenium is not only for the pdf download, the project do a lot of scrapping with it.
If you are using Azure and you are not able to fidn any solution, I would suggest greating a virtual machine with graphical interface so you can run an instance of ChromeDrive (or another one).

Upload file to WEBPAGE without openfile dialog user intervention

I have a google webpage that has a BROWSE button. When one clicks it an openfile dialog appears and prompts the user to select a file for uploading.
The problem is that the client has a lot of files and field to complete so I first tried to automate this through a browser extension. All worked well besides the file uploading. It seems tht because of security reasons you can't make a browser extension, feed it the path of the filename, and automatically upload it.
I want to automate this upload, field-auto-completion process, INSIDE A .NET APPLICATION, How do I access webpage DOM objects in .NET?
Is there a .NET library that can sweep through and modify DOM nodes as easily as you could inside a browser extension with the added possiblily of automating the BROWSE button openDialog stuff?

How to access clipboard image and save it at server location in asp.net web application?

I wish to have the following feature in my web application:
On the client side When I copy an image from anywhere (it gets loaded to the clipboard), now I wish to have a button on which when I click it should save the image at the server location at some path.
I am ok to use anything javascript, jquery, c# at server side code just need the implementation of the above feature.
Please help.
Thanks a lot in advance.
Vaibhav
Check out this question and answers to it: How does the paste image from clipboard functionality work in Gmail and Google Chrome 12+? .
I think the most difficult part is to get it working in all browsers. So if you need older browsers support you probably should use some flash solution like http://code.google.com/p/zeroclipboard/ .
To save it to server you need some controller's POST action (if using MVC) or webservice or aspx page if using webforms. After getting clipboard image with javascript you send it to the server using AJAX for example.

How to download html source and web contents in Windows Phone?

You can download html source and web contents(.files folder) by right click and "Save As.." in Internet Explorer on PC.
I'd like to do the same way as IE in Windows Phone.
I know how to download html source using WebClient class. But I cannot still download web contents(.files folder).
Does anyone know how to download html source as well as web contents(.files folder) ?
You need to download all the content of a html source and locate contents like images and download them with webclients, you need to code the biggest part of this idea.
here it is a link of an application which allows user to download images from imageboards :
http://www.windowsphone.com/fr-BE/apps/1d2e7d7c-1bab-4656-9db3-35c868e40cfe

Passing file from jQuery Ajax method to Webservice

I've a file upload control in my .aspx page. that file upload only allows excel files. after correct file is posted in that control. I'm rendering that control via JavaScript and passing that file to Web service, which has a method to access and do some calculation on that file.
I read some article for that. there is no such a functionality exist to transfer file via client side. Do you have any suggestion?
There is a HTML5 File upload, but only FF, chrome and Safari support these functions.
What you can do is using HTML5 upload with Flash or iFrame post as backup. A plugin with all browser support for jQuery can be found here.

Categories

Resources