×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Issue with Custom Claims provider / WIF. Sharepoint 2010

Issue with Custom Claims provider / WIF. Sharepoint 2010

Issue with Custom Claims provider / WIF. Sharepoint 2010

(OP)

Hi.
I implemented a custom claims provider in Sharepoint 2010.
My current issue is that when I leave the sharepoint application open for around 40 minutes (so the session ends), once I refresh the page it gives me this error:


Server Error in '/IWeb.STS' Application.

--------------------------------------------------------------------------------

Unable to cast object of type 'Microsoft.IdentityModel.Protocols.WSFederation.SignInRequestMessage' to type 'Microsoft.IdentityModel.Protocols.WSFederation.SignOutRequestMessage'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'Microsoft.IdentityModel.Protocols.WSFederation.SignInRequestMessage' to type 'Microsoft.IdentityModel.Protocols.WSFederation.SignOutRequestMessage'.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  


Stack Trace:
 
[InvalidCastException: Unable to cast object of type 'Microsoft.IdentityModel.Protocols.WSFederation.SignInRequestMessage' to type 'Microsoft.IdentityModel.Protocols.WSFederation.SignOutRequestMessage'.]
   IWeb.STS.Default.Page_PreRender(Object sender, EventArgs e) +365
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnPreRender(EventArgs e) +8687558
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

Unable to cast object of type 'Microsoft.IdentityModel.Protocols.WSFederation.SignInRequestMessage' to type 'Microsoft.IdentityModel.Protocols.WSFederation.SignOutRequestMessage'.


I'm researching about it but can't find any solution.

This is the code that handles this:

 private void SingOutProcess()
        {
            this.logger.Debug("Processing SignOut action");

            // Process signout request.
            SignOutRequestMessage requestMessage = (SignOutRequestMessage)WSFederationMessage.CreateFromUri(Request.Url);
            FederatedPassiveSecurityTokenServiceOperations.ProcessSignOutRequest(requestMessage, User, requestMessage.Reply, Response);
        }

        private void SignInProcess()
        {
            // Process signin request.
            SignInRequestMessage requestMessage = (SignInRequestMessage)WSFederationMessage.CreateFromUri(Request.Url);

            this.logger.Debug("Request.Url ->" + Request.Url);

            if (User != null && User.Identity != null && User.Identity.IsAuthenticated)
            {
                this.logger.Debug("Processing SignIn action");

                SecurityTokenService sts = new CustomSecurityTokenService(CustomSecurityTokenServiceConfiguration.Current);
                SignInResponseMessage responseMessage = FederatedPassiveSecurityTokenServiceOperations.ProcessSignInRequest(requestMessage, User, sts);

                this.logger.Debug("ProcessSignInResponse");

                FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(responseMessage, Response);

                this.logger.Debug("Finish SignInProcess");
            }
            else
            {
                string messageError = "User unauthorized to Access";
                UnauthorizedAccessException ex = new UnauthorizedAccessException(messageError);

                this.logger.ErrorException(messageError, ex);

                throw ex;
            }
        }

Thanks!

Pablo
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close