Tag: web config

WCF IErrorHandler扩展未返回指定的Fault

希望有一些WCF向导可以在这里发现我的错误。 我试图通过RESTful JSON WCF服务上基于IErrorHandler的behaviorExtension设置全局error handling程序。 该方法装饰如下: [OperationContract] [WebGet(UriTemplate = “screens/info”, ResponseFormat = WebMessageFormat.Json)] IErrorHandler实现是: public class ErrorHandler : IErrorHandler { public void ProvideFault(Exception error, MessageVersion version, ref Message fault) { var error = new JsonError { Message = error.Message, FaultCode = -1, StackTrace = error.StackTrace }; fault = Message.CreateMessage(version, “”, ideaScreeningError, new DataContractJsonSerializer( ideaScreeningError.GetType())); // […]

将Windows凭据传递给远程https WCF服务

我需要一些帮助,我正在尝试将Windows凭据传递给WCF服务。 在IIS中,仅为这些服务启用Windows身份validation,并通过https运行。 服务器端配置是: 在客户端: 我试图以这种方式使用服务: Client = new MyServiceClient(); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferPoolSize = long.MaxValue; binding.MaxBufferSize = int.MaxValue; EndpointAddress ep = new EndpointAddress(“https://myserver.net:4343/MyService.svc”); Client = new COMINTSServiceClient(binding, ep); Client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification; Client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; Client.Open(); Array[] obj = Client.RandomMethod(); 此代码对我不起作用: Client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification; Client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; 在服务中,当使用ServiceSecurityContext.Current.WindowsIdentity.Name询问正在调用服务的用户时,总是得到: […]

为RESTful WCF配置SSL绑定。 怎么样?

我当前的配置如下: 当我为我的网站配置了http 和 https绑定时,这种方法有效。 我通过https连接到服务,一切都很好。 现在我想完全删除IIS上的http绑定。 我开始得到这样的错误: 找不到与绑定WebHttpBinding的端点的方案http匹配的基址。 注册的基地址方案是[https]。 [InvalidOperationException:找不到与绑定WebHttpBinding的端点的scheme http匹配的基址。 注册的基地址方案是[https]。] System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri,Binding binding,UriSchemeKeyedCollection baseAddresses)+16582113 System.ServiceModel.Description.ConfigLoader.ConfigureEndpointAddress(ServiceEndpointElement serviceEndpointElement,ServiceHostBase host,ServiceEndpoint endpoint)+117 System.ServiceModel.Description.ConfigLoader.ConfigureEndpoint(StandardEndpointElement standardEndpointElement,ServiceEndpointElement serviceEndpointElement,ContextInformation context,ServiceHostBase host,ServiceDescription description,ServiceEndpoint&endpoint,Boolean omitSettingEndpointAddress)+937 System.ServiceModel.Description.ConfigLoader.LookupEndpoint(ServiceEndpointElement serviceEndpointElement,ContextInformation context,ServiceHostBase host,ServiceDescription description,Boolean omitSettingEndpointAddress)+8728167 System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost host,IDictionary`2 implementedContracts,String multipleContractsErrorMessage,String standardEndpointKind)+982 System.ServiceModel.Web.WebServiceHost.OnOpening()+311 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+612 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath)+255 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)+1172 [ServiceActivationException:由于编译期间发生exception,无法激活服务’/ DEMO / mobile’。 exception消息是:找不到与绑定WebHttpBinding的端点的scheme http匹配的基址。 注册的基地址方案是[https] ..] System.Runtime.AsyncResult.End(IAsyncResult result)+901424 […]

如何动态更改web.config中的连接字符串

我在web.config中定义连接字符串 如何在c#中动态更改连接字符串

从web.config读取成员资格部分

我已经创建了一个自定义MembershipProvider类,到目前为止一直很好,但是,我不知道如何从web.config文件中读取配置设置。 我试图从谷歌和Stackoverflow搜索,似乎有人也遇到了我的问题,并问,但没有给出答案。 这应该是一件简单的事情,但我在网络开发方面非常新,所以从web.config中读取设置似乎对我来说太技术了。 这是我的设置: 我想阅读minRequiredPasswordLength设置,请协助。

如何获取配置元素

直升机 谁能解释我如何从.config文件中获取配置元素。 我知道如何处理属性而不是元素。 例如,我想解析以下内容: <![CDATA[ …. ]]> …. 到目前为止,我的c#代码看起来像这样: public class MyConfiguration : ConfigurationSection { [ConfigurationProperty(“enabled”, DefaultValue = “true”)] public bool Enabled { get { return this[“enabled”].ToString().ToLower() == “true” ? true : false; } } [ConfigurationProperty(“header”)] public string header { ??? } } 它适用于属性,如何处理元素(上面代码中的标题属性)?

不存在的目录/文件Web API(不是控制器)的自定义错误页面

我知道我可以为不存在的控制器或错误的路由设置自定义错误页面但是如果用户试图下载某个目录中不存在的文件,我该如何显示自定义错误页面? 我根本无法工作。 它仍然显示默认错误页面。

如何检索程序集的限定类型名称?

如何生成程序集限定类型名称? 例如,在配置成员资格提供程序时,我必须在“type”属性中为“SqlMembershipProvider”(在此示例中,我已从某处复制以下配置)提供程序集限定类型名称。 如何生成该程序集限定类型名称? 是否必须通过检查assembly类型每次手动输入? [更新] : 更简单的PowerShell版本 PS>([System.String]).AssemblyQualifiedName System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

我们可以在.NET控制台应用程序中拥有多个App.Config文件吗?

我有一个具有App.Confile文件的控制台应用程序 。 现在,这里维护了特定于环境的参数。 现在我想要有多个app.config文件 (比如app.dev.config,app.test.config和app.prod.config )我们如何拥有多个Web.Config文件。 在Web应用程序的情况下,我们可以处理这个,ConfigurationManager将选择相应的Web.Config文件。 在控制台应用程序的情况下,我不确定。 如果是,我们如何拥有多个app.config文件? 感谢您的帮助。 谢谢

连接到CRM

我需要我的网站连接到CRM这是我的代码 var organizationUri = new Uri(ConfigurationManager.AppSettings[“CRMServerUrl”]); //Client credentials var credentials = new ClientCredentials(); credentials.UserName.UserName = @””; credentials.UserName.Password = “”; // Use the Microsoft Dynamics CRM Online connection string from the web.config file named “CrmConnectionStr”. using (OrganizationServiceProxy _service = new OrganizationServiceProxy(organizationUri, null, credentials, null)) { Response.Write(“Connected”); } 这是在我的web.config中 <add key="username" value="” /> <add key="password" value="” /> […]