So I can do the following POST
submit
@Html.BeginForm(null, null, FormMethod.Post, new { @action = "https://externalsite.com/secretroom" })
{
<input id="SECRETCODE" name="SECRETCODE" type="hidden" value="GABEN" />
<input type="submit" value="submit"/>
}
After the submit, it will took me to https://externalsite.com/secretroom
. But as you can see the SECRETCODE
is getting exposed in user HTML page and I don't want that.
So what I'm gonna do is I'm trying to do the POST on my server side.
public ActionResult Test()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://externalsite.com/secretroom");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("SECRETCODE", "GABEN")
});
var result = await client.PostAsync("", content).Result;
if(result.IsSuccessStatusCode)
{
return Redirect("https://externalsite.com/secretroom");
}
}
}
The problem is I can't redirect the user because the externalsite
will deny it and I have no idea/no control over how the secretroom
validation works on externalsite
. It will only allow access if I did it the way I did above.
That being said, is this actually possible?