Azure ACS + Form value storage

后端 未结 2 900
青春惊慌失措
青春惊慌失措 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 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.

提交回复
热议问题