Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on a windows application build in C# .net and I want to download a file from server.
I am able to download if the file is directly present with help of HttpWebRequest. The problem I have is that the download is not a direct process its a three step process
1. Login to the application (from where the file is to be downloaded)
2. redirect the url to another page to accept terms and conditions
3. now again redirect to the desired url to download the file.

I have logged into the web application on the windows application launch. I can use the cookies from this logged in session

Please help in achieving the step 2 and step 3.

Thanks,
Posted

1 solution

To accept the second page you should first get it using a GET using the same cookie returned by login.
Then you should probably post the [accept]
Finally you'll be able to get the desired URL

you can use fiddler[^]to record all those request and it will help you to make the same request in your C# program.
 
Share this answer
 
Comments
Lalit Jankiram Sonawane 26-Jun-12 6:29am    
Hi,

Thanks for the hint.Actually we have CookieContainer of our application after login, that passed to second stage url and they are working fine.
But the problem remaining is that it's only work when fiddler is running at back end. As fiddler become off our application response as time out.(At the time of file download url response).Can you please guide what is the difference in both cases.
Pascal Ganaye 26-Jun-12 8:48am    
Without being able to see what's going it is hard to tell.
I you can write some source I'll try to see what's wrong.
Lalit Jankiram Sonawane 27-Jun-12 6:36am    
Hi sir,

Thanks a lot to you for ready to help me,
but i got solution at

http://stackoverflow.com/questions/1030218/httpwebreqest-works-with-fiddler-on-otherwise-timeout

which suggest to close the response after its use is complete,other wise next response will continue to buffer the data on the same line opened previously.
Sergey Alexandrovich Kryukov 16-Nov-12 22:40pm    
In a nutshell, it should be something like this, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900