I have a situation where i will have to download the file from the website. It is a secured site (https) and also It requires the client certificate authentication.
I have a client certificate and managed to get in. After logged in, when i tried to download the file, i am not able to download the file. In turn, the file contains the html with csrftoken. How to get this token id? In order to download the file i need this token. Could someone share what kind of authentication this, and how can i get the csrf token id using c#.
Thanks
It is not authentication. Its security to prevent cross site request forgery .
The technique is:
In your case the workflow should be near to this:
HTTP GET
) to see info in their screen. hidden field
in the generated Form
with the CSRF token. POST
when click on a button with the following data: File identification he wants to download and the CSRF token. POST
. So, if you want to download a file programmatically with C# I think that you should do a GET
first as if you were a webBrowser; retrieve the CSRF token parsing the responsed HTML and send a POST
whith the file and the CSRF token.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.