我需要的是在 SL 应用程序和 Ria 服务之间保持连接。超时通过后,它会在第一次服务调用时引发异常。
我试图做的是定期调用:
var client = new WebClient();
client.DownloadStringAsync(new Uri("../SomePage.aspx", UriKind.Relative));
和服务方法:
svc.HeartBeat();
定期我的意思是每 X 秒一次,其中 X < 超时。
我正在测试心跳和身份验证之间的 60 秒延迟设置为:
<authentication mode="Forms">
<forms timeout="2" slidingExpiration="true" />
</authentication>
无论如何,3分钟后我得到:
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.ServiceModel.DomainServices.Client.DomainOperationException: Invoke operation 'HeartBeat' failed. Access to operation 'HeartBeat' was denied.
w System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
w System.ServiceModel.DomainServices.Client.InvokeOperation.Complete(Exception error)
w System.ServiceModel.DomainServices.Client.DomainContext.CompleteInvoke(IAsyncResult asyncResult)
w System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass38.<InvokeOperation>b__34(Object )
和
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/11.0.0.0
Date: Mon, 16 Sep 2013 09:46:37 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 5108
Connection: Close
[Exception: Access denied.]
Pol.Backend.Web.SystemMessageViewer.Page_Load(Object sender, EventArgs e) in c:\Users\xyz\Documents\Visual Studio\Abc.Web\SomePage.aspx.cs:13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
(访问被拒绝时抛出:
if (this.User == null || !this.User.Identity.IsAuthenticated)
{
throw new Exception("Access denied.");
}
)
我还可以做些什么?