【发布时间】:2012-08-19 02:03:39
【问题描述】:
我正在 .Net 4 中开发 Rest Service,我需要执行重定向。
对我正在做的事情的一点描述:我有一个包含一个按钮的 silverlight 应用程序。当我单击该按钮时,我会向我的 REST 服务发送一个带有一些信息的 POST 请求。根据这些信息,我创建了一个 URL 并(尝试)重定向浏览器。这是服务中方法的代码:
[WebInvoke(Method = "POST", UriTemplate = "OpenBinder")]
public void OpenBinder(int someId)
{
string url = getUrl(someId);
if (WebOperationContext.Current != null)
{
WebOperationContext.Current.OutgoingResponse.Location = url;
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect;
}
}
这似乎执行正确,但是当我在客户端调用 EndGetResponse 时,我看到发生了“安全错误”。这是 System.Security.SecurityException,但我没有得到比这更多的细节。关于这里可能发生什么的任何想法?
【问题讨论】:
-
这是不正确的。否则他们不会在属性上暴露设置器,尽管我明白你的意思。
标签: c# rest exception-handling http-status-code-301 securityexception