I'm trying to get an authenication cookie from an website. I have managed to get this working with an tcl-script. The script looks like this:
proc get_cookie { connector_id } {
global USER PASSWORD URL
set post_url "[get_proxy_url $connector_id]/httpaccess.net/login"
set post_data "user=[urlencode ${USER}]&password=[urlencode ${PASSWORD}]&url=[urlencode $URL]&serviceId=${connector_id}&token=12345"
catch {
exec wget --post-data $post_data --no-check-certificate $post_url --max-redirect=0 -q -S -O - 2>@1
} stderr
if [string match "*HTTP/1.1 302 Found*" $stderr] {
if [regexp {Location: *https://[0-9a-z\-.]+/httpaccess.net/([^/]+)/} $stderr dummy cookie] {
return $cookie
}
}
error "Error getting login cookie for $connector_id: $stderr"
}
Now I'm trying to get this to work in an c# application. But it is not working I'm only getting the html code of the homepage. My code looks like that now. What is the problem?
public MainWindow()
{
InitializeComponent();
string user = "man@gmail.de";
string password = "xxxxxx";
string url = "http://dev.net/testfiles/test_5kB.htm";
string connectorId = "SDYYYYYYYHDMN354KS59";
string post_data = string.Format("user={0}&password={1}&url={2}&serviceId={3}&token={4}", user, password, url, connectorId, "12345");
var cli = new WebClient();
var data = cli.UploadString("https://http.aa.net/xxx/httpaccess.net/login", post_data);
}