I am implementing a basic authentication WCF service in ASP.NET using Visual Studio 2010. I accomplished this by roughly following the first few parts of this guide.
I have the default ASP.NET Web Site (in VS2010) login page set up to use my WCF service to authenticate a user, using this code-behind and an <asp: Login> property:
protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
{
bool isAuthenticated = false;
string customCredential = "Not used by the default membership provider.";
bool isPersistent = LoginUser.RememberMeSet; // Authentication ticket remains valid across sessions?
AuthenticationServiceClient authClient = new AuthenticationServiceClient();
isAuthenticated = authClient.Login(LoginUser.UserName, LoginUser.Password, customCredential, isPersistent);
e.Authenticated = isAuthenticated;
authClient.Close();
}
Furthermore, I had this working when I used IIS Express, but I have since moved to IIS 7.5.
When the above function gets called, an exception is thrown on the call to authClient.Login(...).
The usual error page pops up with this to say:
Server Error in ‘/AuthClientSite’ Application.
AuthenticationService is disabled.
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.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: AuthenticationService is disabled.
As this code is nearly identical to what worked on IIS Express, and given that it seems like my service is just disabled, I’m guessing its a setting somewhere in IIS that needs to be fixed.
I am wrapping the System.Web.ApplicationServices.AuthenticationService service as seen in the link from above.
Any ideas of what’s going on would be a great help. I’ve tried so many different things over the past few days I can’t remember and/or list them all, but I’ll do my best to answer all your questions/comments.
So I figured out my problem. I needed to add these lines to the Web.config file in the web site running the service:
Hope this helps anyone who runs into this problem in the future.