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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:55:36+00:00 2026-05-30T14:55:36+00:00

I have a very simple WCF4 Restful web service which uses WcfRestContrib to allow

  • 0

I have a very simple WCF4 Restful web service which uses WcfRestContrib to allow custom Basic Authentication. It works great when the client preemptively supplies a username and password but if they don’t it returns a 400 Bad Request response rather than challenging the client to supply credentials (through a 401 response).

The service is using the declarative approach to implementing WcfRestContrib by decorating the necessary classes with Attributes. Here is my ServiceContract declaration:

// Standard attributes here
[WebAuthenticationConfiguration(typeof(WebBasicAuthenticationHandler),
                                typeof(SecurityValidator),
                                false,
                                "SearchService")
]
public class SearchService

Which only has one very simple operation:

// Standard attributes here
[OperationAuthentication]
SearchResponse Fetch(SearchRequest request)

And my UserNamePasswordValidator looks like (though it probably doesn’t matter since it only gets called when credentials are passed):

public override void Validate(string userName, string password)
{
    // TODO: Insert login validation logic here.

    // To indicate login failure, throw a FaultException
    // throw new FaultException("Unknown Username or Incorrect Password");

    // Just return to indicate that the username and password are valid
    return;
}

I tried to debug WcfRestContrib and found that the WebBasicAuthenticationHandler class is throwing a BasicAuthorizationException (which is only caught in framework code), however, for some reason it isn’t transforming the exception into a 401.

Based on what I’ve read on the WcfRestContrib github site, there is an issue posted by its author (Mike O’Brian) saying that he’d like to see it return anything other than a 401 which I read as it currently returns the 401 challenge.

If this functionality is there then what am I missing, or am I doing something else wrong?

UPDATE

If there is not a way to do this with WcfRestContrib, is there an alternative way to achieve this (beyond using the standard Windows-based Basic Authentication in IIS)? I’m open to any (other) alternative solution.

  • 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-30T14:55:37+00:00Added an answer on May 30, 2026 at 2:55 pm

    I figured it out. I needed to decorate my ServiceContract with the ErrorHandlerAttribute:

    // Standard attributes here
    [WebAuthenticationConfiguration(typeof(WebBasicAuthenticationHandler),
                                typeof(SecurityValidator),
                                false,
                                "SearchService"),
     ErrorHandler(typeof(WebErrorHandler))]
    public class SearchService
    

    Just by adding the [ErrorHandler(typeof(WebErrorHandler))] attribute to the service makes all of the magic happen. I knew it had to be something simple, just wish I would have seen it before flattening my forehead on my desk.

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

Sidebar

Related Questions

I have very simple iPhone app, which uses just UIButtons , UIlabels , UITableView
I have a very simple table called Member , which consists of the following:
I have a very simple highcharts js chart, which has dates on x-axis and
I have written very very simple console application which supports some command line options.
I have very simple query that calls a UDF which splits a field by
What am I missing? I have very simple client and server. The server uses
I have very simple html and js files - which I've included below. What
I have very simple: [PrincipalPermission(SecurityAction.Demand, Role = Administrator)] public partial class _Default : System.Web.UI.Page
I have a very simple problem which requires a very quick and simple solution
I have a very simple WPF application in which I am using data binding

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.