servicestackservicestack-auth

How to redirect to a post upon authentication in ServiceStack


Maybe I am trying to do something stupid but...

I am attempting to build a ServiceStack OAuth Provide for Azure AD. The redirect URI is passed through by the SS Authentication but I am not sure what to do when the initiating request is a POST rather than a GET. The final redirect is always a GET and I cannot work out how to preserve the initial form data.

Amy I trying to do something reasonable? Any clues on where I should look to preserve my sanity?


Solution

  • You can't redirect to a POST reliably, one solution is to return HTML that auto submits a FORM POST:

    var sb = new StringBuilder();
    sb.Append("<html>");
    sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
    sb.AppendFormat("<form name='form' action='{0}' method='post'>",postbackUrl);
    sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", id);
    // Other params go here
    sb.Append("</form>");
    sb.Append("</body>");
    sb.Append("</html>");
    return sb.ToString();