草庐IT

target_user

全部标签

c# - 登录成功后User.Identity.IsAuthenticated为false

登录成功后需要直接获取UserIdGuid。以下代码不起作用:if(Membership.ValidateUser(txtUsername.Value,txtPassword.Value)){FormsAuthentication.SignOut();FormsAuthentication.SetAuthCookie(txtUsername.Value,true);if(HttpContext.Current.User.Identity.IsAuthenticated){//doesn'trunGuidpuk=(Guid)Membership.GetUser().ProviderUse

c# - 如何在 Asp.Net MVC 4 中模拟 HttpContext.User.Identity.Name

我在Controller中有使用HttpContext的代码publicActionResultIndex(){varcurrentUser=HttpContext.User.Identity.Name;......}当尝试像这样使用NUnit编写测试时[Test]publicvoidCanDisplayRequest(){//Actvarresult=(ViewResult)_requestController.Index();//AssertAssert.IsInstanceOf(resut.Model);}测试将失败,因为它找不到HttpContext那么我如何模拟HttpCon

c# - 打开项目时找不到 Microsoft.CompactFramework.CSharp.targets

我尝试在VisualStudio2008中创建一个智能设备项目。目标平台:WindowsMobile5.0PocketPCSDK。.NETCompactFramework版本:.NETCompactFramework3.5但是我得到以下错误: 最佳答案 它的文档很少。必须安装.NETCompactFrameworkRedistributable和PowerToys才能使所有必要的文件(例如MSBuild目标文件)可用于编译。 关于c#-打开项目时找不到Microsoft.CompactF

c# - 如何解决警告 "Referenced assembly targets a different processor than the application"

我已经能够构建我的Windows窗体应用程序来访问SQLServer中的数据库。除了可以备份/恢复数据库的部分之外,应用程序的所有部分都能够访问服务器。在这部分我无法访问服务器上的数据库并且已经开始相信这是因为这些警告。以下内容的确切含义是什么?我该如何更正它们?Referencedassembly'c:\ProgramFiles\MicrosoftSQLServer\90\SDK\Assemblies\Microsoft.SqlServer.Replication.dll'targetsadifferentprocessorthantheapplicationReferencedas

c# - 链接 : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor

我们正在使用VS2013和.Net4.5.1(最近迁移,但此错误来自.Net4.0)。只有在平台目标x64中编译项目时才会出现此错误。这真的是一个会在运行时中断的错误吗?为什么MSBUILD不能正确解析这个mrcorlib.dll?这仅发生在VS2010中创建的项目中,而不会发生在新创建的项目中。我在这里错过了什么。我所有的第三方程序集都是x64位的。在TeamCity构建服务器中,出现以下错误:GenerateSatelliteAssemblies[17:01:18]AL[17:01:18]C:\ProgramFiles(x86)\MicrosoftSDKs\Windows\v8.1

c# - 具有 HttpContext.Current.User.Identity.IsAuthenticated 的 Webmethods 在 Azure 上不活动后停止工作

我正在使用使用Ajax(json)/Webmethod函数的页面测试Azure服务器。其中一些函数在运行代码之前会检查HttpContext.Current.User.Identity.IsAuthenticated。不幸的是,如果用户已登录并且页面没有向服务器发出完整的回发请求,则只有那些检查HttpContext.Current.User.Identity.IsAuthenticated的webmethods函数会在一对夫妇之后完全停止运行分钟没有给出任何错误。他们甚至不运行else代码块(见下文)。我已经在本地服务器上测试了这些页面,一切正常,即使在长时间不活动之后也是如此。这是

c# - SignalR OnDisconnected - 处理聊天室 "User is Online"的可靠方法?

我正在实现一个聊天室。到目前为止,一切都很好——用户可以通过JS客户端从他们的浏览器发送消息,我可以使用C#客户端来做同样的事情——这些消息被广播给其他用户。现在,我正在尝试实现“在线用户”。我的方法如下:OnConnected-将数据库中的用户更新为IsOnline=trueOnDisconnected-如果用户没有任何其他连接,则将数据库中的用户更新为IsOnline=false我将状态存储在数据库中,因为无论如何我都必须在数据库中查询用户缩略图-这似乎是在中心使用词典的一种简单替代方法。我遇到的问题是OnDisconnected并不总是为每个客户端ID调用-陈旧的连接阻止了“如果

c# - SQL 错误 : Incorrect syntax near the keyword 'User'

我正在使用SQL将数据插入到使用C#的SQL数据库文件中,如下所示。Stringcs=System.Configuration.ConfigurationManager.ConnectionStrings["connection1"].ConnectionString;SqlConnectionconn=newSqlConnection(cs);Stringsql="INSERTINTOUser(login,password,status)"+"VALUES(@login,@password,@status)";SqlCommandcomm=newSqlCommand(sql,conn

c# - HttpContext.Current.User.Identity.Name 如何知道存在哪些用户名?

这不一定是个问题,我只是好奇它是如何工作的。我有一个方法:publicstaticboolUserIsAuthenticated(){boolisAuthed=false;try{if(HttpContext.Current.User.Identity.Name!=null){if(HttpContext.Current.User.Identity.Name.Length!=0){FormsIdentityid=(FormsIdentity)HttpContext.Current.User.Identity;FormsAuthenticationTicketticket=id.Tick

c# - System.IO.Exception 错误 : "The requested operation cannot be performed on a file with a user-mapped section open."

我在写入XML文件时收到一个非常奇怪的IOException:System.IO.IOException:Therequestedoperationcannotbeperformedonafilewithauser-mappedsectionopen.atSystem.IO.__Error.WinIOError(Int32errorCode,StringmaybeFullPath)atSystem.IO.FileStream.Init(Stringpath,FileModemode,FileAccessaccess,Int32rights,BooleanuseRights,FileSh