My goal is to be able to collect login information for another site, fill out the form (as provided and published by the site), submit it and have the URL in the form open up already logged into a client account. Typically, this form is filled out programmatically, and the user just presses a button and bingo, they're logged in and the new web page opens. I'm trying to skip the part where a user has to press a button to submit the form, and just go ahead with that action since my app already has all that information and really doesn't need the user to click AGAIN to get to where she needs to be.
The form code looks like this (this is a Blazor server app Razor component):
<form action="https://app.website.net/site/access/login" method=POST target=_NEW>
<input type=HIDDEN name=UID value="9144412" />
<input type=HIDDEN name=action value=DirectLogin />
<input type=HIDDEN name=col_email value="@email" />
<input type=HIDDEN name=col_password value="@acctpassword" />
<input type=SUBMIT name=SUBMIT value="Click here to access your control panel." />
</form>
Here is the bit of code I tried to submit this form. It works, but what I really need to happen is for the form to submit the user information here, AND open up the dashboard that is called by it.
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://cp.goodbyebots.com/site/access/login"))
{
request.Content = new StringContent("UID=9144412 & col_password="+acctpassword+"& col_email="+email+" & action=DirectLogin");
request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
var response = await httpClient.SendAsync(request);
//await JSRuntime.InvokeVoidAsync("open", "https://app.website.net/site/access/login", "_self", request.Content);
}
}
The httpClient.SendAsync(request); line works just fine, and the server respond with a 200 status, so it works.
That last line was commented because it just didn't work. I was hoping that the successful submission of the credentials through the SendAsync would do the trick and perhaps the credentials would be still in-session when the next line was called, but nope. That's not how it works.
Any ideas how to do this?