Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:09:53+00:00 2026-05-23T07:09:53+00:00

I have a WCF service configured to use custom UserName validation via the overridden

  • 0

I have a WCF service configured to use custom UserName validation via the overridden Validate() method of the System. IdentityModel.Selectors. UserNamePasswordValidator class.

When the validation fails, I throw a SecurityTokenValidationException.

The way it was built, in my client, I’m receiving a CommuinicationException with the message: The remote server returned an error: NotFound.

What’s the best way to handle this exception in the client side?

My validation code:

if (user == null || (Environment.TickCount - user.LastCall) > 300000)
{
    if (!LoginUser.ValidateUser(userName, password))
    {
        throw new SecurityTokenValidationException("Usuário/Senha inválido");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:09:54+00:00Added an answer on May 23, 2026 at 7:09 am

    Throwing an exception from a service will (I believe) fault the channel, and the client will receive a a non-descriptive message. This is by design – WCF “hides” exceptions on the service side.

    To return an error to the client so the client can handle it you should use a FaultException. You can specify a FaultContract for the operation and that will be returned to the client.

    Do a search on error handling in WCF and you should get plenty of examples. I’m short on time or I’d add some, but hopefully this will get you pointed in the right direction.

    Edited to add

    Change the line

    throw new SecurityTokenValidationException("Usuário/Senha inválido");
    

    to

    throw new FaultException("Usuário/Senha inválido");
    

    Throwing the FaultException will prevent the communication from being faulted – the client can then receive the exception, know it was due to validation failure, and decide what to do from that point (retry, prompt the user to reenter credentials, etc).

    This is a very simple change and the example is to illustrate the point. The links I posted below will give more detailed information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to configure my WCF service to use a custom username validator
I have an IIS-hosted WCF service which is configured to use basicHttpBinding with transport
I have a WCF service configured to use ASP.NET session state. I have tested
I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
I have a WCF service and a client, that uses a custom UserNamePasswordValidator for
I am trying to configure my WCF Service to be HTTPS. I have configured
I have WCF service and Silverlight Client. I use PollingDuplexElement. On server side I
I have created a WCF service which does not use the app.config to configure
I am learning and designing a WCF service. I have picked to use Windows
We have Durable Service which is configured to use SqlPersistenceProvider. For each and every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.