简体   繁体   English

服务器错误,WCF服务已禁用

[英]Server error, WCF service disabled

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 . 我正在使用Visual Studio 2010在ASP.NET中实现基本身份验证WCF服务。我通过大致遵循本指南的前几部分来完成此操作

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: 我有默认的ASP.NET网站(在VS2010中)登录页面设置为使用我的WCF服务来验证用户,使用此代码隐藏和<asp: Login>属性:

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. 此外,当我使用IIS Express时,我有这个工作,但我已经转移到IIS 7.5。

When the above function gets called, an exception is thrown on the call to authClient.Login(...) . 调用上面的函数时,调用authClient.Login(...)会抛出异常。

The usual error page pops up with this to say: 弹出通常的错误页面,说:

Server Error in '/AuthClientSite' Application. '/ AuthClientSite'应用程序中的服务器错误。

AuthenticationService is disabled. AuthenticationService已禁用。

Description: An unhandled exception occurred during the execution of the current web request. 描述:执行当前Web请求期间发生未处理的异常。 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. 异常详细信息:System.ServiceModel.FaultException`1 [[System.ServiceModel.ExceptionDetail,System.ServiceModel,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]:AuthenticationService已禁用。

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. 由于此代码与IIS Express上的代码几乎完全相同,并且考虑到我的服务似乎已被禁用,我猜它在IIS中的某个位置需要修复。

I am wrapping the System.Web.ApplicationServices.AuthenticationService service as seen in the link from above . 我正在包装System.Web.ApplicationServices.AuthenticationService服务,如上面的链接所示

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: 我需要将这些行添加到运行该服务的网站中的Web.config文件中:

<system.web.extensions>
    <scripting>
        <webServices>
            <authenticationService enabled="true"
                requireSSL = "false"/>
        </webServices>
    </scripting>
</system.web.extensions>

Hope this helps anyone who runs into this problem in the future. 希望这有助于将来遇到此问题的任何人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM