场景:使用SqlRoleProvider进行Sql Server 2012数据库服务器身份验证的WCF服务.WCF托管在IIS7 Web服务器上.
请看这个错误:
System.NullReferenceException:未将对象引用设置为对象的实例.
在System.Web.Security.Roles.GetRolesForUser(String username)
RoleManagement已启用.
在我的本地开发机器(服务器2012,iis7)上,这工作正常.当我登录并调用该方法时,将检索角色.
在另一台服务器(测试环境)上,它无法正常工作.我可以登录(用户通过用户身份验证并通过sql server数据库)但是当我尝试检索该用户的角色时,我得到一个nullreferenceexception.
这怎么可能,有没有人有任何线索可以解决这个问题?
最好的祝福.
我正在尝试创建自定义webpart.要实现错误处理,我想写入事件日志.为此,我正在尝试使用以下代码;
protected void btnExceptionTester_Click(object sender, EventArgs e)
{
try
{
throw new Exception("this is a test");
}
catch (Exception ex)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
EventLog.WriteEntry("TestWebpart", ex.ToString(), EventLogEntryType.Error);
});
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试执行此代码时,我收到一个sharepoint错误页面(未处理的异常).当我查看事件日志时,我看到以下消息; "不允许请求注册表访问".
我在完全信任级别下运行(仅用于测试).有人能指出我需要写什么样的特权才能写入事件日志?或者还有另一种方法吗?
帮助大大的appriciated!
我正在编写一个非常小的应用程序来创建和测试用于sharepoint的caml查询.在执行GetListItems方法时,我收到以下异常;
System.Net.WebException: "The request failed with an empty response."
Run Code Online (Sandbox Code Playgroud)
该服务位于https地址(ssl).我按如下方式设置服务;
result = new ListService.Lists();
result.Url = siteUrl;
result.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
Run Code Online (Sandbox Code Playgroud)
我调用GetListItems()方法如下;
xmlResult = spList.GetListItems(listName, string.Empty, camlQuery, null, string.Empty, null, string.Empty);
Run Code Online (Sandbox Code Playgroud)
我试图找出为什么我得到空结果消息.我也尝试过其他方法(即GetListCollection),但无济于事.
起初我认为问题可能是URL(http而不是https),但事实并非如此.我甚至用wireshark检查了它,以确保使用正确的URL.
有人来解决这个问题,你是如何解决的?
在针对sharepoint list.asmx服务运行caml查询时,我有这种奇怪的行为,GetListItems方法也返回已删除的项目;
found item: test
found item: already done
found item: recurring
found item: recurring event 3-4
found item: Deleted: recurring event 3-4
found item: Deleted: recurring event 3-4
found item: Deleted: recurring event 3-4
found item: Deleted: recurring event 3-4
found item: Deleted: recurring event 3-4
found item: todays event 15-16 //<- NOT DELETED YET
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?我是否需要对caml查询应用特殊过滤器?我目前正在查询如下;
<Query>
<OrderBy>
<FieldRef Ascending='TRUE' Name='EventDate' />
</OrderBy>
<Where>
<Eq>
<FieldRef Name='EventDate' />
<Value Type='DateTime'><Today /></Value>
</Eq>
</Where>
</Query>
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试了什么; 1.清除回收站中的所有内容2.在sharepoint网络服务器上执行iisreset
请注意; …