I recently started using a custom ServiceHostFactory because I want to use dependency injection with WCF. Both my client and service are being run from VS2010 on my local machine and the service is using the ASP.NET Development Server. Why am I having this problem now? I've had success with wsHttpSecurity in the past, having both the client and service on my local machine. I really think the only difference here is the use of a ServiceHostFactory. I've tried using the userPrincipalName attribute but I'm not even sure what I should be putting in for the value. Should it be MachineName\username? Will this attribute make a difference? I'd greatly appriciate any help you can provide.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
UserNamePrincipal describes service credentials. If you set UPN to some account you claim that service will be hosted in process running under that account. This information is passed in WSDL to client. When client opens channel to the service it first validate that service is running under claimed account (some security handshake). If not exception is thrown because service is not authenticated. If you run the service on development server you have to set UPN to your current account.