草庐IT

current_directory

全部标签

c# - 将 HttpContext.Current.User 与异步等待一起使用的正确方法

我正在使用异步操作并像这样使用HttpContext.Current.UserpublicclassUserService:IUserService{publicILocPrincipalCurrent{get{returnHttpContext.Current.UserasILocPrincipal;}}}publicclassChannelService:IDisposable{//IntheservicelayerpublicChannelService():this(newEntities.LocDbContext(),newUserService()){}publicChan

c# - 为什么 Active Directory 会验证最后一个密码?

我正在研究一个简单的解决方案来更新ActiveDirectory中的用户密码。我可以成功更新用户密码。更新密码工作正常。假设用户已将密码从MyPass1更新为MyPass2现在,当我运行自定义代码以使用以下方法验证用户凭据时:using(PrincipalContextpc=newPrincipalContext(ContextType.Domain,"TheDomain")){//validatethecredentialsboolisValid=pc.ValidateCredentials("myuser","MyPass2");}//returnstrue-whichisgood

c# - 为什么 Active Directory 会验证最后一个密码?

我正在研究一个简单的解决方案来更新ActiveDirectory中的用户密码。我可以成功更新用户密码。更新密码工作正常。假设用户已将密码从MyPass1更新为MyPass2现在,当我运行自定义代码以使用以下方法验证用户凭据时:using(PrincipalContextpc=newPrincipalContext(ContextType.Domain,"TheDomain")){//validatethecredentialsboolisValid=pc.ValidateCredentials("myuser","MyPass2");}//returnstrue-whichisgood

c# - 在 Active Directory : A device attached to the system is not functioning 中创建用户

考虑此代码尝试创建一个ActiveDirectory帐户。它在这里使用一组特定的数据生成异常。目前尚不清楚是什么导致了异常。varuser=newUserPrincipal(someValidUserContext,".x-xyz-t-FooFooBarTest","somePwd",true);user.UserPrincipalName=".x-xyz-t-FooFooBarTest@foobarbatbaz.net";user.SamAccountName=".x-xyz-t-FooFooBarTest";user.DisplayName="SomeString16charslo

c# - 在 Active Directory : A device attached to the system is not functioning 中创建用户

考虑此代码尝试创建一个ActiveDirectory帐户。它在这里使用一组特定的数据生成异常。目前尚不清楚是什么导致了异常。varuser=newUserPrincipal(someValidUserContext,".x-xyz-t-FooFooBarTest","somePwd",true);user.UserPrincipalName=".x-xyz-t-FooFooBarTest@foobarbatbaz.net";user.SamAccountName=".x-xyz-t-FooFooBarTest";user.DisplayName="SomeString16charslo

c# - HttpContext.Current.Cache.Insert 和 HttpContext.Current.Cache.Add 有什么区别

我正在开发一个ASP.NETweb应用程序,我想实现缓存,所以我想知道HttpContext.Current.Cache.Insert和HttpContext.Current之间的区别.Cache.Add哪个更好? 最佳答案 两者之间的主要区别在于,如果缓存中已存在同名对象,则对Cache实例调用的Insert方法将替换对象,而Add方法调用将失败(取自Add和Insert方法在其各自的MSDN引用页上的Remarks段落):添加Callstothismethodwillfailifanitemwiththesamekeyparam

c# - HttpContext.Current.Cache.Insert 和 HttpContext.Current.Cache.Add 有什么区别

我正在开发一个ASP.NETweb应用程序,我想实现缓存,所以我想知道HttpContext.Current.Cache.Insert和HttpContext.Current之间的区别.Cache.Add哪个更好? 最佳答案 两者之间的主要区别在于,如果缓存中已存在同名对象,则对Cache实例调用的Insert方法将替换对象,而Add方法调用将失败(取自Add和Insert方法在其各自的MSDN引用页上的Remarks段落):添加Callstothismethodwillfailifanitemwiththesamekeyparam

c# - 单元测试 HttpContext.Current.Cache 或 C# 中的其他服务器端方法?

为使用HttpContext.Current.Cacheclass的类创建单元测试时,我在使用NUnit时出错。功能是基本的-检查一个项目是否在缓存中,如果不在,则创建它并将其放入:if(HttpContext.Current.Cache["Some_Key"]==null){myObject=newObject();HttpContext.Current.Cache.Insert("Some_Key",myObject);}else{myObject=HttpContext.Current.Cache.Get("Some_Key");}从单元测试中调用它时,遇到第一个Cache行时会

c# - 单元测试 HttpContext.Current.Cache 或 C# 中的其他服务器端方法?

为使用HttpContext.Current.Cacheclass的类创建单元测试时,我在使用NUnit时出错。功能是基本的-检查一个项目是否在缓存中,如果不在,则创建它并将其放入:if(HttpContext.Current.Cache["Some_Key"]==null){myObject=newObject();HttpContext.Current.Cache.Insert("Some_Key",myObject);}else{myObject=HttpContext.Current.Cache.Get("Some_Key");}从单元测试中调用它时,遇到第一个Cache行时会

c# - HttpContext.Current 未在 MVC 4 项目中解析

我想使用ImageResizer(来自ImageResizingdotnet)。我通过NuGet为MVC安装了ImageResizer。但是当我去使用示例中的以下代码时://Loopthrougheachuploadedfileforeach(stringfileKeyinHttpContext.Current.Request.Files.Keys){HttpPostedFilefile=HttpContext.Current.Request.Files[fileKey];if(file.ContentLengthand,or//evenasantiziedversionoftheor