frame-ancestors指令废弃了X-Frame-Options标头.如果资源同时具有两个策略,则应该强制执行frame-ancestors策略,并且应该忽略X-Frame-Options策略.
因此,根据我的理解,如果两者Content-Security-Policy和X-Frame-Options标题都存在,那么X-Frame-Options应该被忽略.
我有一个带有两个标题的Web应用程序,看起来像Firefox 38忽略Content-Security-Policy标题并使用X-Frame-Options标题代替.
我的示例标题是:
Content-Security-Policy:frame-ancestors 'self' local.com *.local.com
X-Frame-Options:Allow-From http://local.com
Run Code Online (Sandbox Code Playgroud)
我希望我的框架可以从local.com和所有子域访问.Local.com就是一个例子.如果X-Frame-Options标题存在,那么它只允许http://local.com,但如果我删除它,那么Firefox使用Content-Security-Policy标题并适用于域和子域.
这是否意味着Firefox没有实现这一部分?或者它只是太新的规范而且Firefox还没有实现它?有没有其他方法可以强制Content-Security-Policy使用标头?
我知道Chrome工作正常,Content-Security-PolicyIE可以正常使用X-Frame-Options,但看起来我无法组合两个标头,因为Firefox的工作方式不正确.
一种可能的方法是X-Frame-Options仅针对IE 发送,而Content-Security-Policy针对所有其他方式,但是有更好的方法吗?
谢谢!
security firefox frame x-frame-options content-security-policy
我有一个关于使用CodeFirst方法的EntityFramework的问题.基于EntityConnection源代码和文档,我无法使用已打开的SqlConnection创建它.它要求应该关闭.我们有一些不同的数据库数据层(nHibernate等),如果我们可以在它们之间重用相同的SqlConnection,那将是很好的.但似乎,EntityFramework不允许这样做.我可以将关闭的SqlConnection传递给DbContext,但是对我来说关闭每个DbContext的连接并不好.
有没有办法重用打开的SQL连接?
编辑
EF转到OpenSource后,我能够更新它.我改变的唯一一行是在System.Data.Entity.Core.EntityClient.EntityConnection类的构造函数中.
if (connection.State != ConnectionState.Closed)
{
//throw new ArgumentException(Strings.EntityClient_ConnectionMustBeClosed);
}
Run Code Online (Sandbox Code Playgroud)
在我评论抛出异常之后,我能够重用现有的已打开的SQL连接,并且在DBContext使用它之后,它不会关闭它,并且它仍然可用于其他东西.
我的示例代码:
var connection = new SqlConnection(connectionString);
connection.Open();
MetadataWorkspace workspace = GetWorkspace(connection); // I loaded it from the same context, and save it in memory.
EntityConnection eConnection = new EntityConnection(workspace, connection);
using(var context = new EFContext(connection, false))
{
var someData = context.SomeTable.ToList();
}
connection.Close();
Run Code Online (Sandbox Code Playgroud) 当MS发布用于Visual Studio 2012的Git Tools时,他们说它需要更新2 - http://www.hanselman.com/blog/GitSupportForVisualStudioGitTFSAndVSPutIntoContext.aspx.
我正在开发一些Visual Studio扩展,这对我来说很有意思,它们在Update 2 for Extensions API中已经改变了,这在Update1\RTM中是不存在的.
我检查了Update 2发行说明,但找不到与Extensions相关的任何内容.来源 - http://support.microsoft.com/kb/2797912/en-us
visual-studio-addins visual-studio-extensions visual-studio-2012
我正在处理我需要访问数据库的应用程序.使用using语句很好,因为"using" statement is to ensure that the object is always disposed correctly, and it doesn't require explicit code to ensure that this happens.我有点困惑在哪里使用"使用",哪里不使用.
public int route(Route r)
{
try
{
using (SqlConnection con = new SqlConnection(connectionString))
{
using(SqlCommand com = new SqlCommand("",con))
{
using (SqlDataReader sdr = com.ExecuteReader())
{
}
}
}
}
catch (Exception e)
{
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 HTTP/HTTPS 代理,需要使用用户名和密码进行身份验证。如何使用 C# selenium chrome webdriver 来做到这一点?
string host = proxies[count].Split(':')[0];
int port = Convert.ToInt32(proxies[count].Split(':')[1]) + 1;
string prox = host + ":" + port.ToString();
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy = prox;
proxy.SslProxy = prox;
options.Proxy = proxy;
Run Code Online (Sandbox Code Playgroud)
options 是我分配给驱动程序的 ChromeOptions 类。