コード例 #1
0
        public ActionResult RegisterNew()
        {
            StartRegistrationAttemptResponse response = null;

            try
            {
                using (WebSSOServiceSoapClient client = new WebSSOServiceSoapClient("WebSSOServiceSoapClient"))
                {
                    client.Open();

                    StartNewUserRegistrationAttemptRequest request = new StartNewUserRegistrationAttemptRequest()
                    {
                        // In this example, SuccessUri and FailureUri are set to the same value. The response
                        // to each End<X>Attempt() contains enough information to distinguish
                        // between a success result and a failure result. RegisterNewResult() illustrates
                        // how to do this.
                        SuccessUri = RegisterNewResultUri,
                        FailureUri = RegisterNewResultUri,

                        CancelAllowed = true,
                        SignOnAfterSuccess = true,

                        // The user will be signed on following a successful registration, so we need to
                        // specify the application session length.
                        SessionLengthMinutes = HttpContext.Session.Timeout,
                        SessionLengthMinutesSpecified = true,
                    };

                    response = client.StartNewUserRegistrationAttempt(request);
                }
            }
            catch (Exception ex)
            {
                Session["Message"] = HttpUtility.HtmlEncode(string.Format("Exception of type {0} raised when calling WebSSOService.StartNewUserRegistrationAttempt(). {1}", ex.GetType().FullName, ex.Message));

                return SignUpPageRedirect;
            }

            // The registration attempt ID is placed in the session to act as a "marker" that
            // a registration attempt is in progress. It's used later to avoid a call to
            // EndNewUserRegistrationAttempt() if no registration attempt is in progress.

            Session["NewUserRegistrationAttempt"] = response.RegistrationAttemptId;

            return Redirect(response.RedirectUri);
        }