【问题标题】:Server error, WCF service disabled服务器错误,WCF 服务已禁用
【发布时间】:2012-05-30 14:43:31
【问题描述】:

我正在使用 Visual Studio 2010 在 ASP.NET 中实现一个基本的身份验证 WCF 服务。我大致遵循this guide 的前几部分来完成此操作。

我设置了默认的 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();
}

此外,我在使用 IIS Express 时也能正常工作,但后来我转移到了 IIS 7.5。

当上述函数被调用时,调用authClient.Login(...)时会抛出异常。

通常的错误页面会弹出这样说:

“/AuthClientSite”应用程序中的服务器错误。

AuthenticationService 被禁用。

说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]:AuthenticationService 已禁用。

由于此代码与 IIS Express 上的代码几乎相同,而且我的服务似乎刚刚被禁用,我猜测它是 IIS 中某个需要修复的设置。

我正在包装System.Web.ApplicationServices.AuthenticationService 服务,如the link from above 所示。

任何关于正在发生的事情的想法都会有很大帮助。在过去的几天里,我尝试了很多不同的东西,我记不起来和/或全部列出来了,但我会尽力回答你所有的问题/cmets。

【问题讨论】:

  • IIS7.5的App pool运行的Identity是什么?应用程序池是在运行还是停止?
  • 我是所有术语的新手,但根据 IIS 管理器,我的网站使用 Identity: "ApplicationPoolIdentity" 运行。它的状态是“开始”,所以我猜它正在运行。此外,它的 v4.0 .NET 和集成管道模式。

标签: asp.net wcf visual-studio-2010 authentication iis


【解决方案1】:

所以我发现了我的问题。我需要将这些行添加到运行服务的网站中的 Web.config 文件中:

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

希望这对以后遇到此问题的人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    相关资源
    最近更新 更多