2

我在 Visual Studio 中创建的事件接收器有问题。在特殊情况下,我想重定向到一个站点。但是事件接收器只显示错误页面,错误为“事件接收器已取消请求”。我可以使用 properties.ErrorMessage 属性修改此消息,但我想重定向并且没有错误消息!这是我的代码:

if (NoErrors == false)
{

                    properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
                    properties.RedirectUrl = SPUrlUtility.CombineUrl(properties.WebUrl, @"MyEditForm.aspx?"
                                            + "Mode=Upload"
                                            + "&CheckInComment="
                                            + "&ID=" + properties.ListItem.ID
                                            + "&RootFolder=%2Fsites%2FSuppliers%2FLists%2FDocument%20Center"
                                            + "&IsDlg=1"
                                            + "&ContentTypeId=" + properties.ListItem.ContentType.Id
                                            + "&IsDlg=1"
                                            + "&error=" + AllErrorsText);
}

我做错了什么?有人可以帮忙吗?提前致谢。

编辑: 解决方案:在错误变量“AllErrorsText”中使用相对 URL 并且没有特殊字符。

string TestUrl = "MyEditForm.aspx?"
                 + "Mode=Upload"
                 + "&CheckInComment="
                 + "&ID=" + properties.ListItem.ID
                 + "&RootFolder=%2Fsites%2FSuppliers%2FLists%2FDocument%20Center"
                 + "&IsDlg=1"
                 + "&ContentTypeId=" + properties.ListItem.ContentType.Id
                 + "&IsDlg=1"
                 + "&error=" + AllErrorsTextUrl;
properties.RedirectUrl = TestUrl;
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
4

1 回答 1

0

我自己找到了解决方案:

在错误变量“AllErrorsText”中使用相对 URL,并且没有特殊字符。

    string TestUrl = "MyEditForm.aspx?"
                 + "Mode=Upload"
                 + "&CheckInComment="
                 + "&ID=" + properties.ListItem.ID
                 + "&RootFolder=%2Fsites%2FSuppliers%2FLists%2FDocument%20Center"
                 + "&IsDlg=1"
                 + "&ContentTypeId=" + properties.ListItem.ContentType.Id
                 + "&IsDlg=1"
                 + "&error=" + AllErrorsTextUrl;
properties.RedirectUrl = TestUrl;
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
于 2014-07-22T12:11:23.050 回答