I'm sending AJAX form from page in http scheme to https url (the domain, and the appliaction is the same). I use MVC 3 Ajax helper:
@using (Ajax.BeginForm(MVC.Payment.Confirm(), new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = "myId",
InsertionMode = InsertionMode.Replace,
OnBegin = "$('#popupAjaxLoader').show();",
OnSuccess = "$('#popupAjaxLoader').hide();",
Url = "https://same.domain/payment/confirm"
}, new { @action = "https://same.domain.com/payment/confirm" }))
{
...
}
In the application I use forms authentication:
<forms loginUrl="~/Account/LogOn" timeout="2880" name="MYCOOKIENAME" />
In firebug I can see that the authentication cookie is not sent to the server when submiting the form, so the handler fails (the request need to be authorized). How can I force Ajax.BegiForm to attach authentication cookie?
UPDATE:
It turned out that the solution given by counsellorben works if there is no need to receive any information back from the ajax request. Sending Ajax POST from HTTP to HTTPS works fine (cookies are not attached, so you have to POST all neccessary data as hidden form fields), but the server response is not accessible for javascript because of Same Origin Policy. Eventually I had to abandon Ajax and place the form inside iframe referencing HTTPS url which seems to be the ultimate solution for this problem.