gpt4 book ai didi

asp.net - 切换到 SSL 时 WCF 中的访问被拒绝(ASP.NET Forms 身份验证)

转载 作者:太空宇宙 更新时间:2023-11-03 13:48:47 24 4
gpt4 key购买 nike

我有一个 Web 应用程序,用户使用 ASP.NET Forms 身份验证登录。在 Web 应用程序中有一个 Silverlight 应用程序。 Silverlight 应用程序调用同一服务器上的 WCF Web 服务。 WCF 服务不允许匿名访问,因此每个服务函数都有:

    [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]

当我在 IIS 上部署并使用 HTTP 时,所有这些都有效。

但是我想使用 SSL,所以我尝试配置它。我在 IIS 中使用 https 绑定(bind)创建了一个网站。我可以使用 https 和 ASP.NET 表单例份验证登录该站点。我可以下载 Silverlight 应用程序,但是当 Silverlight 尝试调用 WCF Web 服务(在同一台服务器上,在/Services 下)时,我现在得到拒绝访问(我在使用 http 时没有得到这个)。

Aspx 页面在根目录中,.svc 文件在/Services 下,图像在/Img 下,.css 在/Styles 下我的网络配置:

<location path="Img">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

<location path="Styles">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

<location path="Services">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

<system.web>
<authentication mode="Forms">
<forms name=".COOKIEDEMO"
loginUrl="~/Login.aspx"
protection="All"
timeout="30"
path="/"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<compilation strict="true" debug="true" explicit="true" targetFramework="4.0" />

<!-- Customizing the membership provider-->
<membership defaultProvider="SaverpMesProvider" userIsOnlineTimeWindow="30">
<providers>
<add name="SaverpMesProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" applicationName="SaverpMES" />
</providers>
</membership>

<roleManager enabled="true" defaultProvider="SaverpMesRoleProvider">
<providers>
<add name="SaverpMesRoleProvider"
connectionStringName="LocalSqlServer"
applicationName="SaverpMes"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>

<profile inherits="SaverpMes.Web.MesProfile" defaultProvider="SaverpMesProfileProvider">
<providers>
<add name="SaverpMesProfileProvider"
connectionStringName="LocalSqlServer"
applicationName="SaverpMes"
type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>

</system.web>

<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinaryBinding">
<binaryMessageEncoding/>
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<extensions>
<behaviorExtensions>
<add name="silverlightFaultExtension" type="SaverpMes.Web.Wcf.SilverlightFaultBehavior, SaverpMes.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="wcfFaultExtension" type="SaverpMes.Web.Wcf.WcfFaultBehaviorExtensionElement, SaverpMes.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Product.FrontEnd.WcfService.ProductService">
<endpoint address="" behaviorConfiguration="SilverlightFaultsBehavior"
binding="customBinding" bindingConfiguration="CustomBinaryBinding"
name="ProductServiceEndpoint" contract="Product.FrontEnd.Contract.IProductService" />
</service>
<service behaviorConfiguration="ServiceBehavior" name="Product.FrontEnd.WcfService.PublicProductService">
<endpoint address="" behaviorConfiguration="SilverlightFaultsBehavior"
binding="customBinding" bindingConfiguration="CustomBinaryBinding"
name="PublicProductServiceEndpoint" contract="Product.SG.IPublicProductService" />
</service>
<service behaviorConfiguration="ServiceBehavior" name="Identification.FrontEnd.WcfService.FrontEndService">
<endpoint address="" behaviorConfiguration="SilverlightFaultsBehavior"
binding="customBinding" bindingConfiguration="CustomBinaryBinding"
name="IdentificationServcieEndpoint" contract="Identification.FrontEnd.Contract.IFrontEndService" />
</service>
<service behaviorConfiguration="ServiceBehavior" name="Common.WcfService.CommonService">
<endpoint address="" behaviorConfiguration="SilverlightFaultsBehavior"
binding="customBinding" bindingConfiguration="CustomBinaryBinding"
name="CommonServiceEndpoint" contract="Common.Contract.ICommonService" />
</service>
</services>

<behaviors>
<endpointBehaviors>
<behavior name="SilverlightFaultsBehavior">
<silverlightFaultExtension/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<wcfFaultExtension/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

基本上,我在 http 网站和 https 网站之间的 web.config 中所做的更改是 customBinding 下的 httpsTransport 和 serviceMetadata 下的 httpsGetEnabled。

非常感谢任何想法!

最佳答案

我通过在 web.config 中添加 serviceAuthorization principalPermissionMode="None"使其正常工作。

<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="None" />
<wcfFaultExtension />
</behavior>
</serviceBehaviors>

关于asp.net - 切换到 SSL 时 WCF 中的访问被拒绝(ASP.NET Forms 身份验证),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8900932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com