C# login to webpage doesn't work, but cURL command works properlyBest way to parse command line arguments in C#?How to display request headers with command line curlPost data to other site using PHP and save outputget value from curl responsePHP cURL to login to a sitecURL POST request after loginAFNetworking check responseCURL gives HTTP/1.1 302 Moved TemporarilyConverting Curl command to PHP not workingC# REST API server side code for curl command
In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?
Why is "I let him to sleep" incorrect (or is it)?
Is there an in-universe explanation given to the senior Imperial Navy Officers as to why Darth Vader serves Emperor Palpatine?
RAID0 instead of RAID1 or 5, is this crazy?
What's the difference between a variable and a memory location?
Are sweatpants frowned upon on flights?
Was a six-engine 747 ever seriously considered by Boeing?
What's the point of fighting monsters in Zelda BotW?
Can a Sorcerer use the Careful Spell Metamagic option on spells with optional saving throws?
Convert shapefille to KML
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
Group by consecutive index numbers
Why do IR remotes influence AM radios?
Why doesn't Starship have four landing legs?
Why are JWST optics not enclosed like HST?
How to investigate an unknown 1.5GB file named "sudo" in my Linux home directory?
Cauterizing a wound with metal?
Why military weather satellites?
is "prohibition against," a double negative?
Coupling two 15 Amp circuit breaker for 20 Amp
Necessity of tenure for lifetime academic research
How do you say "half the time …, the other half …" in German?
Generic method to call API functions with simple retrial on errors
Is rebooked flight considered a delay
C# login to webpage doesn't work, but cURL command works properly
Best way to parse command line arguments in C#?How to display request headers with command line curlPost data to other site using PHP and save outputget value from curl responsePHP cURL to login to a sitecURL POST request after loginAFNetworking check responseCURL gives HTTP/1.1 302 Moved TemporarilyConverting Curl command to PHP not workingC# REST API server side code for curl command
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have question about my C# code. I write program which first of all login to webpage, then add some contribution to webpage after...
I did it before, that I copy cURL (bash) command and then run it in GitBash, and it works fine.
Now I did it again and one of the headers is XSID, it's something like identificator for correct add contribution to webpage and it's generetated on Server (probably). XSID is very important for me, because without this XSID, which is renew after login, I don't have access to adding contributions to webpage.
cURL Command and echo in GitBash:
Wittner@HP-POWER15-WITTNER MINGW64 ~
$ curl 'https://imhd.sk/po/prihlasenie.php' -i -s -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: cookie_notice=1;' -d 'login=user123&password=password'
HTTP/1.1 302 Found
Server: nginx/1.15.5
Date: Wed, 27 Mar 2019 21:48:41 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: PHP/5.6.38
Set-Cookie: xsid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Set-Cookie: xsid=1f3021122747dba70b9e4ab3b5f94d54; path=/; secure
Location: /po/
As I sad in GitBash it's everything good and I have this XSID there, but problem is, that I don't have this XSID in ConsoleProgram in C# and GitBash.
Code in C#:
public static async Task ProgramAsync()
ServicePointManager.ServerCertificateValidationCallback = delegate return true; ;
HttpClient client = new HttpClient(new HttpClientHandler UseCookies = false );
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://imhd.sk/po/prihlasenie.php?target=vyprava");
request.Content = new StringContent("login=user123&password=password", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("Cookie", "cookie_notice=1");
var response = await client.SendAsync(request);
Console.WriteLine(response);
Echo in C# without XSID:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Transfer-Encoding: chunked
Connection: keep-alive
X-UA-Compatible: IE=edge,chrome=1
Date: Wed, 27 Mar 2019 22:17:25 GMT
Set-Cookie: default_web=po; expires=Thu, 26-Mar-2020 22:17:25 GMT; Max-Age=31536000; path=/; domain=imhd.sk
Server: nginx/1.15.5
X-Powered-By: PHP/5.6.38
Content-Type: text/html; charset=UTF-8
Another problem is that in GitBash it's HTTP 302 Found and in ConsoleProgram it's HTTP 200 OK.
What should I change in my Code to get same request with XSID like in GitBash ?
Thanks a lot !
c# curl request response git-bash
add a comment |
I have question about my C# code. I write program which first of all login to webpage, then add some contribution to webpage after...
I did it before, that I copy cURL (bash) command and then run it in GitBash, and it works fine.
Now I did it again and one of the headers is XSID, it's something like identificator for correct add contribution to webpage and it's generetated on Server (probably). XSID is very important for me, because without this XSID, which is renew after login, I don't have access to adding contributions to webpage.
cURL Command and echo in GitBash:
Wittner@HP-POWER15-WITTNER MINGW64 ~
$ curl 'https://imhd.sk/po/prihlasenie.php' -i -s -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: cookie_notice=1;' -d 'login=user123&password=password'
HTTP/1.1 302 Found
Server: nginx/1.15.5
Date: Wed, 27 Mar 2019 21:48:41 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: PHP/5.6.38
Set-Cookie: xsid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Set-Cookie: xsid=1f3021122747dba70b9e4ab3b5f94d54; path=/; secure
Location: /po/
As I sad in GitBash it's everything good and I have this XSID there, but problem is, that I don't have this XSID in ConsoleProgram in C# and GitBash.
Code in C#:
public static async Task ProgramAsync()
ServicePointManager.ServerCertificateValidationCallback = delegate return true; ;
HttpClient client = new HttpClient(new HttpClientHandler UseCookies = false );
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://imhd.sk/po/prihlasenie.php?target=vyprava");
request.Content = new StringContent("login=user123&password=password", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("Cookie", "cookie_notice=1");
var response = await client.SendAsync(request);
Console.WriteLine(response);
Echo in C# without XSID:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Transfer-Encoding: chunked
Connection: keep-alive
X-UA-Compatible: IE=edge,chrome=1
Date: Wed, 27 Mar 2019 22:17:25 GMT
Set-Cookie: default_web=po; expires=Thu, 26-Mar-2020 22:17:25 GMT; Max-Age=31536000; path=/; domain=imhd.sk
Server: nginx/1.15.5
X-Powered-By: PHP/5.6.38
Content-Type: text/html; charset=UTF-8
Another problem is that in GitBash it's HTTP 302 Found and in ConsoleProgram it's HTTP 200 OK.
What should I change in my Code to get same request with XSID like in GitBash ?
Thanks a lot !
c# curl request response git-bash
add a comment |
I have question about my C# code. I write program which first of all login to webpage, then add some contribution to webpage after...
I did it before, that I copy cURL (bash) command and then run it in GitBash, and it works fine.
Now I did it again and one of the headers is XSID, it's something like identificator for correct add contribution to webpage and it's generetated on Server (probably). XSID is very important for me, because without this XSID, which is renew after login, I don't have access to adding contributions to webpage.
cURL Command and echo in GitBash:
Wittner@HP-POWER15-WITTNER MINGW64 ~
$ curl 'https://imhd.sk/po/prihlasenie.php' -i -s -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: cookie_notice=1;' -d 'login=user123&password=password'
HTTP/1.1 302 Found
Server: nginx/1.15.5
Date: Wed, 27 Mar 2019 21:48:41 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: PHP/5.6.38
Set-Cookie: xsid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Set-Cookie: xsid=1f3021122747dba70b9e4ab3b5f94d54; path=/; secure
Location: /po/
As I sad in GitBash it's everything good and I have this XSID there, but problem is, that I don't have this XSID in ConsoleProgram in C# and GitBash.
Code in C#:
public static async Task ProgramAsync()
ServicePointManager.ServerCertificateValidationCallback = delegate return true; ;
HttpClient client = new HttpClient(new HttpClientHandler UseCookies = false );
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://imhd.sk/po/prihlasenie.php?target=vyprava");
request.Content = new StringContent("login=user123&password=password", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("Cookie", "cookie_notice=1");
var response = await client.SendAsync(request);
Console.WriteLine(response);
Echo in C# without XSID:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Transfer-Encoding: chunked
Connection: keep-alive
X-UA-Compatible: IE=edge,chrome=1
Date: Wed, 27 Mar 2019 22:17:25 GMT
Set-Cookie: default_web=po; expires=Thu, 26-Mar-2020 22:17:25 GMT; Max-Age=31536000; path=/; domain=imhd.sk
Server: nginx/1.15.5
X-Powered-By: PHP/5.6.38
Content-Type: text/html; charset=UTF-8
Another problem is that in GitBash it's HTTP 302 Found and in ConsoleProgram it's HTTP 200 OK.
What should I change in my Code to get same request with XSID like in GitBash ?
Thanks a lot !
c# curl request response git-bash
I have question about my C# code. I write program which first of all login to webpage, then add some contribution to webpage after...
I did it before, that I copy cURL (bash) command and then run it in GitBash, and it works fine.
Now I did it again and one of the headers is XSID, it's something like identificator for correct add contribution to webpage and it's generetated on Server (probably). XSID is very important for me, because without this XSID, which is renew after login, I don't have access to adding contributions to webpage.
cURL Command and echo in GitBash:
Wittner@HP-POWER15-WITTNER MINGW64 ~
$ curl 'https://imhd.sk/po/prihlasenie.php' -i -s -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: cookie_notice=1;' -d 'login=user123&password=password'
HTTP/1.1 302 Found
Server: nginx/1.15.5
Date: Wed, 27 Mar 2019 21:48:41 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: PHP/5.6.38
Set-Cookie: xsid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Set-Cookie: xsid=1f3021122747dba70b9e4ab3b5f94d54; path=/; secure
Location: /po/
As I sad in GitBash it's everything good and I have this XSID there, but problem is, that I don't have this XSID in ConsoleProgram in C# and GitBash.
Code in C#:
public static async Task ProgramAsync()
ServicePointManager.ServerCertificateValidationCallback = delegate return true; ;
HttpClient client = new HttpClient(new HttpClientHandler UseCookies = false );
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://imhd.sk/po/prihlasenie.php?target=vyprava");
request.Content = new StringContent("login=user123&password=password", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("Cookie", "cookie_notice=1");
var response = await client.SendAsync(request);
Console.WriteLine(response);
Echo in C# without XSID:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Transfer-Encoding: chunked
Connection: keep-alive
X-UA-Compatible: IE=edge,chrome=1
Date: Wed, 27 Mar 2019 22:17:25 GMT
Set-Cookie: default_web=po; expires=Thu, 26-Mar-2020 22:17:25 GMT; Max-Age=31536000; path=/; domain=imhd.sk
Server: nginx/1.15.5
X-Powered-By: PHP/5.6.38
Content-Type: text/html; charset=UTF-8
Another problem is that in GitBash it's HTTP 302 Found and in ConsoleProgram it's HTTP 200 OK.
What should I change in my Code to get same request with XSID like in GitBash ?
Thanks a lot !
c# curl request response git-bash
c# curl request response git-bash
asked Mar 27 at 22:18
Erik WittnerErik Wittner
33 bronze badges
33 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387336%2fc-sharp-login-to-webpage-doesnt-work-but-curl-command-works-properly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387336%2fc-sharp-login-to-webpage-doesnt-work-but-curl-command-works-properly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown