我试图在 MOSS 文档库的事件处理程序中获取 HTTPContext,但我所拥有的只是 HTTPContext.Current 的空值,我在列表上执行相同的操作并返回 HTTPContext。有没有办法获取文档库中的HTTPContext来访问HTTPContext.Request方法?
感谢您的帮助
这是代码:
public class TestContextListItemEventReceiver : SPItemEventReceiver
{
HttpContext current;
static object obj;
/// <summary>
/// Initializes a new instance of the Microsoft.SharePoint.SPItemEventReceiver class.
/// </summary>
public TestContextListItemEventReceiver()
{
current = HttpContext.Current;
}
public override void ItemAdding(SPItemEventProperties properties)
{
obj = current;
}
}
步骤1
宣布:
private HttpContext currentContext;
static HttpContext _stCurrentContext;
Step 2
currentContext = HttpContext.Current; // in constructor
Step3
public override void ItemAdding(SPItemEventProperties properties)
_stCurrentContext = currentContext;
Step 4
public override void ItemAdded(SPItemEventProperties properties)
if (_stCurrentContext.Request.Files[0].ContentLength > 0)
HttpPostedFile uploadfile = _stCurrentContext.Request.Files[0];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)