Tag: asp.net 4.5

使用C#,WCF SOAP使用者使用WSSE纯文本身份validation?

我有一个WCF SOAP使用者,它由Visual Studio 2012从WSDL实现。 WSDL由PeopleTools生成。 基础对象的类型为System.ServiceModel.ClientBase 。 我需要SOAP请求类似于: [plain text username goes here] [plain text password goes here] Aren Cambre 这是我们最接近的: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue urn:uuid:3cc3f2ca-c647-466c-b38b-f2423462c837 http://www.w3.org/2005/08/addressing/anonymous http://[internal URL to soap listener] http://schemas.xmlsoap.org/ws/2005/02/sc/sct http://schemas.xmlsoap.org/ws/2005/02/trust/Issue 256 FgMBAFoBAABWAwFQ9IhUFGUO6tCH+0baQ0n/3us//MMXzQA78Udm4xFj5gAAGAAvADUABQAKwBPAFMAJwAoAMgA4ABMABAEAABX/AQABAAAKAAYABAAXABgACwACAQA= 你会发现两个问题: 没有纯文本WSSE凭据。 传递服务不使用的二进制forms的凭据。 身份validation在Body ,而不是Header 。 该请求省略了InputParameters 。 这是必不可少的C#代码: var service = new ServiceWithBizarreNameFromPeoplesoft(); if (service.ClientCredentials == null) throw new NullReferenceException(); service.ClientCredentials.UserName.UserName […]

成功登录后,User.Identity.IsAuthenticated为false

成功登录后,我需要直接获取UserId Guid。 以下代码不起作用: if (Membership.ValidateUser(txtUsername.Value, txtPassword.Value)) { FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie(txtUsername.Value, true); if (HttpContext.Current.User.Identity.IsAuthenticated) { // doesn’t run Guid puk = (Guid)Membership.GetUser().ProviderUserKey; } } 以下代码确实有效: if (Membership.ValidateUser(txtUsername.Value, txtPassword.Value)) { FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie(txtUsername.Value, true); MembershipUser user = Membership.GetUser(txtUsername.Value); if (user != null) { Guid puk = (Guid)user.ProviderUserKey; } } 为什么会这样? 除了SetAuthCookie之外还有更多的事情SetAuthCookie吗?

了解C#5 async / await中的上下文

我是否正确async / await本身与并发/并行无关,只不过是继续传递样式(CPS)实现? 真正的线程是由await传递/恢复的SynchronizationContext实例执行的? 如果这是正确的,我有关于SynchronizationContext的以下问题: 它保证在同一个线程上执行延续。 但是,是否有任何保证线程的上下文信息是持久的? 我的意思是Name , CurrentPrincipal , CurrentCulture , CurrentUICulture等。它依赖于框架(ASP.NET,WinForms,WCF,WPF)吗?