Azure ACS + Form value storage

后端 未结 2 899
青春惊慌失措
青春惊慌失措 2021-01-25 14:48

I\'m using Azure ACS in my ASP.net MVC 3 website (hosted in Azure too), the scenario is this: A user first enters my website and fills a one field form, then they need to chose

相关标签:
2条回答
  • 2021-01-25 14:58

    Another approach would be to save whatever data you need to pass around in the Database, and just pass around some ID that refers back to the database record. You'll pass this ID to IP and back through wctx (as Mike mentioned above).

    This will solve the issue of limited length of URLs (in case your data is very large). Of course you would need to manage deletion of this data, but this shouldn't be hard.

    0 讨论(0)
  • 2021-01-25 15:19

    You can pass state around in the WS-Federation redirect sequence using the wctx URL parameter. In the action that handles the initial POST request, you should get hold of the form parameter you want to keep, then redirect to you identity provider selection page (this will have to be a custom page) with the form parameter appended to the URL. When the user selects an IP on your page, you can pass the parameter on again using the wctx parameter. The WS-Federation passive requestor profile says that this should be returned to you eventually when the IP redirects the user back to your site.

    This has some details

    http://msdn.microsoft.com/en-us/library/bb608217.aspx

    Edit: To get the wctx parameter out of the request when the user finally comes back to your app. Put something like this in the action code:

    var fam = FederatedAuthentication.WSFederationAuthenticationModule;
    
    if (fam.CanReadSignInResponse(System.Web.HttpContext.Current.Request, true))
    {
        string wctxValue = this.HttpContext.Request.Form["wctx"];
    }
    

    My preference is to have the wcxt parameter represent a redirect URL (URL encoded) with your parameter as a query parameter in that so it be a URL encoded version of this:

    wctx=https://yourserver/yourapp/yourpage?yourparameter=foo
    

    Then the action that was receiving the redirect from the ACS would simply pull out the value of wctx and do a redirect to it without any more processing. This keeps things simple.

    0 讨论(0)
提交回复
热议问题