首次启动WCF服务时获得通知的最佳方法是什么?
是否有类似于ASP.NET应用程序的Global.asax中的Application_Start方法?
如何判断远程消息队列是否存在?该文档指出"存在"方法不适用于远程计算机.
以下是无效的(我知道队列路径是准确的,因为我能够将消息发送到队列):
if (!MessageQueue.Exists(@"FormatName:Direct=TCP:192.168.2.58\Private$\MyQueue")) throw new InvalidOperationException("Queue does not exist");
问题是将消息发送到其后没有侦听队列的网络地址不会导致异常.为无效的队列地址抛出异常对我们的应用程序至关重要.
在我的服务实施中,我有:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
在我的.config文件中,我有:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
和:
<system.web.extensions> <scripting> <webServices> <authenticationService enabled="true" requireSSL = "false"/> </webServices> </scripting> </system.web.extensions>
和:
<authentication mode="Forms" />
在我的服务的"登录"方法中,我有:
FormsAuthentication.SetAuthCookie(request.UserName, false);
但是,当我检查:
HttpContext.Current.User.Identity.Name
这是一个空字符串.我错过了什么?