小编Bra*_*ing的帖子

UserPrincipal.GetGroups与UserPrincipal.GetAuthorizationGroups?

我使用ASP.Net 4.0 MVC来查询活动目录.我试图获取用户的组成员资格列表,并迭代它们.我有一个奇怪的问题.要获得我正在使用的组:

   PrincipalSearchResult<Principal> groups = up.GetGroups();
Run Code Online (Sandbox Code Playgroud)

哪个在localhost上工作得很好但在移动到IIS6时返回一个空集.所以我尝试使用这个:

    PrincipalSearchResult<Principal> groups = up.GetAuthorizationGroups();
Run Code Online (Sandbox Code Playgroud)

哪个在IIS6上运行良好,但在localhost上返回一个空集.这两种方法有什么区别?为什么我可以在IIS6中使用一个而不在localhost上使用?为什么我可以在localhost而不是IIS6中使用另一个?

c# active-directory asp.net-mvc-3

9
推荐指数
2
解决办法
5990
查看次数

Server.ScriptTimeout在范围内设置全局?

根据我的经验,无论是作为经典ASP还是ASP.NET开发者,我总是理解设置Server.ScriptTimeout值的调用是当前请求的本地范围.换句话说,调用Server.ScriptTimeout = 600会将当前请求的处理时间设置为10分钟.对其他资源的后续或甚至并发请求将使用默认设置Server.ScriptTimeout.

最近在代码审查中,我被告知设置Server.ScriptTimeout为值会设置站点中每个页面的处理时间,直到应用程序池被回收.建议的"修复"类似于以下内容:

public class MyPage : Page {
  private const int desiredTimeout = 600;
  private int cachedTimeout;

  private void Page_Load(object sender, EventArgs e) {
    // cache the current timeout in a private store.
    cachedTimeout = Server.ScriptTimeout;
    Server.ScriptTimeout = desiredTimeout;
  }

  private void Page_Unload(object sender, EventArgs e) {
    // restore the previous setting for the timeout
    Server.ScriptTimeout = cachedTimeout;
  }
}
Run Code Online (Sandbox Code Playgroud)

这对我来说似乎很奇怪,因为Server.ScriptTimeout = 1在页面中调用的开发人员可以关闭该站点,因为每个其他页面只允许处理一秒钟.此外,此行为将影响当前Page_Load和Page_Unload事件之间可能发生的任何当前请求 - 这似乎是并发噩梦.

然而,为了彻底,我制作了一个由两页组成的测试工具 …

asp.net

8
推荐指数
1
解决办法
3444
查看次数

无法将类型"System.Int32"强制转换为"System.Object"类型.LINQ to Entities仅支持转换EDM原语或枚举类型

public ViewResult Medicament(string searchTerm)
    {


        if (!String.IsNullOrEmpty(searchTerm))
        {
           var Medicament = from s in db.MEDICAMENTs
                         from j in db.FOURNISSEURs
                         where s.ID_Fournisseur.Equals(j.CODE_FOUR) &&
                               j.NOM_FOUR.Equals(searchTerm)
                         select s;



             return View(Medicament.ToList().Any());
        }
                return View();
    }
Run Code Online (Sandbox Code Playgroud)

我收到了这条消息:

无法将类型"System.Int32"强制转换为"System.Object"类型.LINQ to Entities仅支持转换EDM原语或枚举类型.

asp.net-mvc

1
推荐指数
1
解决办法
5326
查看次数