我在调用Web服务时遇到此错误:
"远程服务器返回错误:(407)需要代理验证".
我得到了一般的想法,我可以通过添加来获得代码
myProxy.Credentials = NetworkCredential("user", "password", "domain");
Run Code Online (Sandbox Code Playgroud)
或者在代码中使用DefaultCredentials.我的问题是,没有这个,对Web服务的调用在生产中工作.
似乎有一个涉及Machine.config的非代码解决方案,但它是什么?目前我无法访问生产盒的machine.config文件,看看它是什么样的.我尝试更新我的machine.config如下,但我仍然得到407错误.
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<bypasslist>
<clear />
</bypasslist>
<proxy proxyaddress="myproxy:9000"
usesystemdefault="false"
bypassonlocal="true"
autoDetect="False" />
</defaultProxy>
</system.net>
Run Code Online (Sandbox Code Playgroud) .net c# proxy-authentication machine.config http-status-code-407
我想在Silverlight中的多个实体之间共享相同的数据库信息..但我希望连接字符串被命名为xyz并让每个人都从machine.config访问该连接字符串...
实体的元数据部分将是不同的,因为我没有将实体命名为相同的..
我可以在该元数据部分放置多个实体吗?
这是一个例子..我想使用这个连接字符串,但请注意我在元数据部分放了多个实体.
基本上我想要这个连接字符串
<add name="XYZ" connectionString="metadata=res://*/ModEntity.csdl|res://*/ModEntity.ssdl|res://*/ModEntity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SomeServer;Initial Catalog=SomeCatalog;Persist Security Info=True;User ID=Entity;Password=SomePassword;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
而这个连接字符串
<add name="XYZ" connectionString="metadata=res://*/Entity.csdl|res://*/Entity.ssdl|res://*/Entity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SOMESERVER;Initial Catalog=SOMECATALOG;Persist Security Info=True;User ID=Entity;Password=Entity;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
制作此连接字符串
<add name="XYZ" connectionString="metadata=res://*/Entity.csdl|res://*/Entity.ssdl|res://*/Entity.msl|res://*/ModEntity.csdl|res://*/ModEntity.ssdl|res://*/ModEntity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SOMESERVER;Initial Catalog=SOMECATALOG;Persist Security Info=True;User ID=Entity;Password=SOMEPASSWORD;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
但它根本行不通.这两个项目都无法连接到它.
string encConnection = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
Type contextType = typeof(test_Entities);
object objContext = Activator.CreateInstance(contextType, encConnection);
return objContext as test_Entities;
Run Code Online (Sandbox Code Playgroud) 我想将machineKey添加到我的machine.config中,因为我正在使用Web场方案中的web.config连接字符串的编程加密.
我的问题是,我在哪里将machineKey放在machine.config文件中?我已经没有可以替换的了,我怀疑它是自动生成的,所以应该放在哪里?
我想提高ASP.NET Web应用程序的性能,并希望在machine.config中更改"processModel"标记.但是我无法修改位于framework目录下的"machine.config"文件.虽然我已禁用该文件的"只读"权限,但它仍无效.
更改machine.config文件中的值有什么影响?这会触发机器上的IISReset吗?如果没有,正在运行的应用程序是否会立即获取添加到此文件的新值?
当用户基于默认的表单身份验证方法登录时,服务器会创建一个包含加密数据的cookie(使用Machine Key作为加密密钥).
这意味着如果有人找到/猜测/访问服务器的机器密钥,他将登录到Web应用程序.
我开发了一些在4台服务器上的应用程序.所以,我为machine.config中的所有服务器硬编码了相同的机器密钥,我无法使用自动生成模式.
asp.net forms-authentication machinekey machine.config formsauthenticationticket
使用实体框架调用WCF .net 4.0服务时,我们收到此错误.
The 'DbProviderFactories' section can only appear once per config file
Run Code Online (Sandbox Code Playgroud)
它是使用EF和其他.net 4.0 WCF服务的服务器上的第一个应用程序没有收到此错误.
有没有办法纠正这个错误,而无需在服务器上编辑机器配置文件?
在我的machine.config文件中,我有以下内容
<configuration>
....
<appSettings>
<add key="key" value="value"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我试图通过使用在asp页面上检索它
ConfigurationManager.AppSettings["key"];
Run Code Online (Sandbox Code Playgroud)
并且每次都返回null.
我最近升级到Vista x64,突然之间,任何.NET程序集都没有读取我的machine.config appSettings块.
在configSections之后,在C:\ Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config中的configProtectedData之前,我有:
<appSettings>
<add key="foo" value="blah"/>
</appSettings>
<system.runtime.remoting>
<customErrors mode="Off"/>
</system.runtime.remoting>
Run Code Online (Sandbox Code Playgroud)
不得不通过以管理员身份运行Notepad ++来保存它,因为它被锁定,否则可能是有充分理由的.在SnippetCompiler或VS .NET 2008中运行以下代码:
foreach(var s in ConfigurationManager.AppSettings.AllKeys)
{
Console.WriteLine(s);
}
AppSettingsReader asr = new AppSettingsReader();
Console.WriteLine(asr.GetValue("foo", typeof(string)));
Run Code Online (Sandbox Code Playgroud)
写出没有密钥并因以下异常而失败:
---
The following error occurred while executing the snippet:
System.InvalidOperationException: The key 'foo' does not exist in the appSettings configuration section.
at System.Configuration.AppSettingsReader.GetValue(String key, Type type)
at MyClass.RunSnippet()
at MyClass.Main()
---
Run Code Online (Sandbox Code Playgroud)
我编写的应用程序使用machine.config作为回退,用于找出用户应该在哪个环境中运行,如果在app.config中找不到它,那么我想避免重写我的应用程序来弄清楚应该像2000年和XP一样工作的东西.
我需要进行一些性能调整,需要修改以下设置:processModel,httpRuntime和connectionManagement.我想这很简单,但我不确定要编辑的两个machine.config文件中的哪一个,或者我都编辑它们?
作为后续问题,如何验证是否已应用设置?
我应该提一下,服务器运行的是带有IIS 6.0(64位)和MSSQL Server Enterprise 2005(64位)的Windows Server 2003 Enterprise(64位).
我在这里先向您的帮助表示感谢!
machine.config ×10
asp.net ×6
.net ×5
c# ×3
.net-2.0 ×1
encryption ×1
iis ×1
iis-7 ×1
machinekey ×1
vista64 ×1
wcf ×1
web-config ×1
windows ×1
winforms ×1