草庐IT

User_Defined

全部标签

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

c# - MVC @RenderSection "sections have been defined but have not been rendered"脚本。多级页面时

我正在使用MVCv4。我有一个“_BootstrapLayout”页面,它定义了所有twitterbootstrap等内容,一个定义网站布局、导航栏等的主页,以及从主页继承的网站页面。_BootstrapLayout.cshtml_MainPage.cshtml@{Layout="~/Views/Shared/_BootstrapLayout.cshtml";}Index.cshtml@{Layout="~/Views/Shared/_MainPage.cshtml";}所以母版页-->主页-->站点页面_BootstrapLayout页面包含脚本的呈现部分@RenderSection

c# - 错误 : Reference to type claims it is defined, 但找不到

我有一个包含3个项目的解决方案:ParsersBase,它定义了一个接口(interface)IParseRuleParsersLibrary,它引用了ParsersBase并定义了一个类HtmlImageUrlParseRule:IParseRuleParsersLibraryTest,它引用了ParsersBase和ParsersLibrary并定义了一个带有一些测试方法的测试类当我尝试构建它时,我收到警告:Referencetotype'AVSoft.ParsersBase.IParseRule'claimsitisdefinedin'c:\Users\Tim\Dropbox\p

c# - 如何使用最小起订量模拟 Controller.User

我有几个ActionMethods可以像这样查询Controller.User的角色boolisAdmin=User.IsInRole("admin");在那个条件下方便地行动。我开始用这样的代码对这些方法进行测试[TestMethod]publicvoidHomeController_Index_Should_Return_Non_Null_ViewPage(){HomeControllercontroller=newHomePostController();ActionResultindex=controller.Index();Assert.IsNotNull(index);}并

c# - 为 WebClient 请求设置 User-Agent header

为WindowsPhone7的WebClient请求设置User-Agentheader的正确方法是什么?我找到了2个选项,但不确定哪一个是正确的。考虑WebClient对象:WebClientclient=newWebClient();我看到了2个选项:使用以下方法设置用户代理:client.Headers["User-Agent"]="myUserAgentString";使用WebHeaderCollection设置用户代理:WebHeaderCollectionheaders=newWebHeaderCollection();headers[HttpRequestHeader.

c# - asp.net MVC3 Razor : display actionlink based on user role

我是MVC的新手。我希望能够为某些用户隐藏一些操作链接。假设我有一个“创建”操作链接,我只希望管理员看到并单击它。我想使用asp.net中可用的某种“loggedintemplate”,但它似乎在razor中不起作用。我可以使用某种带有if语句的代码块来检查当前用户及其角色,但这可能不是最佳做法?我的index.cshtml..//wantsomeadminauthattributehere...@Html.ActionLink("CreateNew","Create")我的Controller..//GET:/Speaker/Create[Authorize(Roles="Admin

docker - Jenkins + Docker : How to control docker user when using Image. 内部命令

尊敬的Stackoverflow社区,我正在尝试使用docker镜像作为构建过程的容器来设置JenkinsCI管道。我正在定义一个Jenkinsfile以将构建管道作为代码。我正在做这样的事情:node{docker.withRegistry('http://my.registry.com','docker-credentials'){defbuildimage=docker.image('buildimage:latest');buildimage.pull();buildimage.inside(""){stage('Checkoutsources'){giturl:'...',c

docker - Jenkins + Docker : How to control docker user when using Image. 内部命令

尊敬的Stackoverflow社区,我正在尝试使用docker镜像作为构建过程的容器来设置JenkinsCI管道。我正在定义一个Jenkinsfile以将构建管道作为代码。我正在做这样的事情:node{docker.withRegistry('http://my.registry.com','docker-credentials'){defbuildimage=docker.image('buildimage:latest');buildimage.pull();buildimage.inside(""){stage('Checkoutsources'){giturl:'...',c

c# - NuGet 包管理器 : 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'

我尝试将AutoMapper添加为在VisualStudioPremium2012上使用NuGet的项目的依赖项,但它失败了。它说:Operationfailed'AutoMapper'alreadyhasadependencydefinedfor'Microsoft.CSharp'.我可以添加其他依赖项。我正在使用VS2012的最新版本的包管理器:NuGetPackageManager2.8.60318.667有什么我应该检查的想法吗? 最佳答案 问题是您的NuGet包管理器太旧了。你需要NuGet2.12因为它支持AutoMap