草庐IT

LZH_USER

全部标签

c# - HttpContext.Current.User.Identity.Name 使用 IIS Express 但不是 Visual Studio Development Server 为空

这个问题在这里已经有了答案:AuthenticationissuewhendebugginginVS2013-iisexpress(9个回答)关闭4年前。HttpContext.Current.User.Identity.Name在VisualStudio设置为“使用本地IISWeb服务器”时为空,但在VisualStudio设置为“使用VisualStudio开发”时正常工作服务器”。希望您可以通过执行以下操作在VisualStudio2010或2012(我都尝试过)中重现此问题:创建一个新的“ASP.NET空Web应用程序”并选择“.NETFramework4”并将其命名为“Win

搭建微服务时 nacos2.2.2报错403 user not found!

1.错误:com.alibaba.nacos.api.exception.NacosException:failedtoreqAPI:/nacos/v1/ns/instanceafterallservers([localhost:8848])tried:ErrCode:403,ErrMsg:WhitelabelErrorPageThisapplicationhasnoexplicitmappingfor/error,soyouareseeingthisasafallback.SatJun1015:35:54GMT+08:002023Therewasanunexpectederror(type=

c# - 为什么我的抽象基 Controller 中的 User(如 User.Identity.Name)为 null?

我在问一个相关的问题,但把标题弄乱了,没人能理解。由于我现在可以更准确地提出问题,因此我决定将其重新表述为一个新问题并关闭旧问题。对此感到抱歉。所以我想做的是将数据(存储在数据库中的自定义用户昵称)传递给LoginUserControl。此登录通过Html.RenderPartial()从母版页呈现,所以我真正需要做的是确保在每次调用时都显示ViewData["UserNickname"]。但是我不想在每个Controller的每个Action中填充ViewData["UserNickname"],所以我决定使用thisapproach并创建一个抽象基础Controller来为我完成工

c# - 为什么我的抽象基 Controller 中的 User(如 User.Identity.Name)为 null?

我在问一个相关的问题,但把标题弄乱了,没人能理解。由于我现在可以更准确地提出问题,因此我决定将其重新表述为一个新问题并关闭旧问题。对此感到抱歉。所以我想做的是将数据(存储在数据库中的自定义用户昵称)传递给LoginUserControl。此登录通过Html.RenderPartial()从母版页呈现,所以我真正需要做的是确保在每次调用时都显示ViewData["UserNickname"]。但是我不想在每个Controller的每个Action中填充ViewData["UserNickname"],所以我决定使用thisapproach并创建一个抽象基础Controller来为我完成工

数据库初始化设置密码时报错"SET PASSWORD has no significance for user 'root'@'localhost' as the authentication met...

1、报错示例Re-enternewpassword:...Failed!Error:SETPASSWORDhasnosignificanceforuser'root'@'localhost'astheauthenticationmethoduseddoesn'tstoreauthenticationdataintheMySQLserver.PleaseconsiderusingALTERUSERinsteadifyouwanttochangeauthenticationparameters.2、去手动配置密码root@LNMP:~#mysqlmysql>ALTERUSER'root'@'loc

c# - 通过 user32.dll 中的 SendInput 发送 key

我正在使用thisboard作为演示目的的键盘。总之,长话短说,除极少数情况外,一切正常。我用SendInput发送击键函数位于user32.dll中。所以我的程序看起来像:staticvoidMain(string[]args){Console.Write("Pressenteranonthenextsecontthekeycombinationshift+endwillbesend");Console.Read();Thread.Sleep(1000);SendKeyDown(KeyCode.SHIFT);SendKeyPress(KeyCode.END);SendKeyUp(Ke

c# - 通过 user32.dll 中的 SendInput 发送 key

我正在使用thisboard作为演示目的的键盘。总之,长话短说,除极少数情况外,一切正常。我用SendInput发送击键函数位于user32.dll中。所以我的程序看起来像:staticvoidMain(string[]args){Console.Write("Pressenteranonthenextsecontthekeycombinationshift+endwillbesend");Console.Read();Thread.Sleep(1000);SendKeyDown(KeyCode.SHIFT);SendKeyPress(KeyCode.END);SendKeyUp(Ke

c# - ASP.NET 成员资格 : how to set the user as logged in

我正在尝试让MembershipProvider工作。到目前为止我有:调用:protectedvoidLogin1_Authenticate(objectsender,AuthenticateEventArgse){if(Membership.ValidateUser(Login1.UserName,Login1.Password)){Response.Redirect("/admin/default.aspx");//Settheuserasloggedin?}}如果我输入正确的登录名/密码,ValidateUser函数将返回true。所以我的问题是:如何将用户设置为已登录?我正在我

c# - ASP.NET 成员资格 : how to set the user as logged in

我正在尝试让MembershipProvider工作。到目前为止我有:调用:protectedvoidLogin1_Authenticate(objectsender,AuthenticateEventArgse){if(Membership.ValidateUser(Login1.UserName,Login1.Password)){Response.Redirect("/admin/default.aspx");//Settheuserasloggedin?}}如果我输入正确的登录名/密码,ValidateUser函数将返回true。所以我的问题是:如何将用户设置为已登录?我正在我

c# - 我如何模拟 User.Identity.GetUserId()?

我正在尝试对包含以下行的代码进行单元测试:UserLoginInfouserIdentity=UserManager.GetLogins(User.Identity.GetUserId()).FirstOrDefault();我只是停留在一点上,因为我无法得到:User.Identity.GetUserId()返回一个值。我一直在尝试以下设置我的Controller:varmock=newMock();mock.Setup(p=>p.HttpContext.User.Identity.GetUserId()).Returns("string");但它给出了“NotSupportedEx