This is one of the things I tried unsuccessfully. It just returns the login page. I think I need to get the session credentials from the WebBrowser cookies and transfer them to the WebRequest Credentials.
Main Topics
Browse All TopicsI'm building a .NET windows forms application to access an ASP.NET web app. The web app allows users to generate custom reports in Excel format and then download them.
I have used a WebBrowser control and DOM to log on to the site and generate the report I want. I'm now trying to download the report without getting the Open/Save UI dialog. I think I can do this by using system.net.webrequest to access the URI of the generated report. The problem is getting the appropriate credentials for the browser session to the webrequest. Running the webrequest now just returns a log-in page for the site. I've tried a number of methods that don't work and hope someone here can point me to the correct way to do this. Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here's a thought, do you think you could get the user to type their login credentials into your app?
if so, If its forms authentication, you could use fiddler or something to enable you to spoof a login.
try this:
open up url you are trying to download in your browser (you should get the login page)
turn on fiddler (http://www.fiddlertool.co
hit "log in"
get the form data from fiddler, use that info to create your web request, like:
(also seems to need a cookie set to work, but doesn't seem to care what that cookie is)
Excellent. I think we're on the right track. Yes, it's forms authentication and I do have access to the user credentials.
When I tried your technique I received the following error:
"An unexpected error has occurred.
Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.Regist
Do I need to grab an event validation token and return it?
Business Accounts
Answer for Membership
by: the_crazedPosted on 2008-01-11 at 03:01:51ID: 20635337
you want to set Credentials and PreAuthenticate on your webrequest object
Select allOpen in new window