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 8170789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:14:52+00:00 2026-06-06T21:14:52+00:00

I started to develop a REST API for my c#/.net app by WCF. I

  • 0

I started to develop a REST API for my c#/.net app by WCF.

I use basic HTTP authentication by a customized UserNamePasswordValidator. It authenticates my API methods.

It based on this sample code and I could make it work without any problem:

public class CustomUserNameValidator : UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {

        if (null == userName || null == password)
        {
            throw new ArgumentNullException("You must provide both the username and password to access this service");
        }

        if (!(userName == "user1" && password == "test") && !(userName == "user2" && password == "test"))
        {
            throw new FaultException("Unknown Username or Incorrect Password");
        }
    }
}

When authentication fails, I can’t send back nothing but a ‘401 Unauthorized’ to the client. I know it is the way it should be, but is it possible somehow send back some detailed information back to my caller in this case? Some customized error message or some more detailed info. If not, my client has only authentication failed http info, and it is not enough in my case.

  • 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-06-06T21:14:53+00:00Added an answer on June 6, 2026 at 9:14 pm

    maybe you should use WebFaultException<> , in my case I used like this : throw new WebFaultException<string>("Bad Request", HttpStatusCode.Unauthorized);

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

Sidebar

Related Questions

When I started to develop with .NET under VS2008 recently, I was very happy
I just started to use Liferay and I want to develop a portlet using
I have started to develop a web app on google's app engine and i
We started to develop a new application using .NET 4.0 Beta 2. Should we
I had a jqGrid displaying perfectly ok. Then I started to develop a basic
I've started Android programming recently so bear with me :) I develop an app
In order to develop an app remote desktop WP7, I started to with a
I have a brief conceptional question: Recently, I started to develop an app in
I started to develop an iPhone App for a client but the binary not
Last week i started to develop an android app and almost done the coding

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.