我昨晚部署了一个ASP.NET MVC应用程序,并发现将IIS7设置为集成模式进行部署的工作量较少.我的问题是有什么区别?使用一个或另一个有什么含义?
我在其部署的服务器之一上使用Windows身份验证的WCF服务出现问题(它是Windows Server 2008 R2计算机),而在我可以访问的所有其他计算机上运行完美(Windows 7,Windows Server) 2008和Windows Server 2008 R2).我设法用一个非常简单的示例应用程序重现了这个问题,该应用程序或多或少完全排除了我的代码作为问题的原因.
我可以重现问题的最小应用程序是对WCF服务项目模板的一个小修改:
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}\nUsername: {1}",
value,
ServiceSecurityContext.Current == null ?
"<null>" :
ServiceSecurityContext.Current.PrimaryIdentity.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
基本上我启用了ASP.NET兼容性(我需要它,因为实际代码使用HttpHandler进行身份验证)并返回经过身份验证的用户的用户名.
内容web.config如下:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding …Run Code Online (Sandbox Code Playgroud)