我有一個非常簡單的ServiceAuthorizationManager(也許是最簡單的),並遵循網絡上的各種教程,但由於某種原因,我的斷點沒有被擊中,這導致我認爲它沒有被調用。ServiceAuthorizationManager不叫
- 創建了一個WCF服務應用程序將其命名爲WcfTest
- 保留了默認類Service1.svc,IService.cs卻改變方法返回一個字符串
- 補充說ServiceAuthorizationManager
- 重寫繼承一個新的類該方法CheckAccessCore()
- 調整web.config文件,以便它使用這個管理器類
運行WCF服務應用程序
大會被稱爲WcfTest
- 所有類居住在該項目的根目錄中沒有文件夾或任何
調用該方法,在這一點上,我希望我的ServiceAuthorizationManager被稱爲還是我錯在這裏?我認爲它的全部目的是在收到的每個請求中都打上自定義的ServiceAuthorizationManager?
在此先感謝,Onam。
需要更多信息讓我知道,會看到這個像鷹一樣,因爲我很困惑,當這應該顯得很簡單。
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "/getIt",ResponseFormat=WebMessageFormat.Json)]
string GetIt();
}
public class Service1 : IService1
{
public string GetIt()
{
return "boo!";
}
}
public class MyServiceMan : ServiceAuthorizationManager
{
protected override bool CheckAccessCore(OperationContext operationContext)
{
try
{
//Some stuff here breakpoint set on above line not hit
return false;
}
catch (Exception e)
{
return false;
}
}
}
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfTest.Service1">
<endpoint address=""
contract="WcfTest.IService1"
binding="webHttpBinding">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceAuthorization serviceAuthorizationManagerType="WcfTest.MyServiceMan,WcfTest" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>