我想不在任何地方缓存我的aspx页面.出于某种原因,IE忽略了从我的母版页设置的元标记
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
Run Code Online (Sandbox Code Playgroud)
我试图看看我是否可以将我的Http响应头设置为"Cache-Control" - "no-cache".设置类似的东西
HttpContext.Current.Response.Headers.Add("Cache-Control", "no-cache");
HttpContext.Current.Response.Headers.Add("Exipres", DateTime.Now.AddDays(-1).ToShortDateString());
Run Code Online (Sandbox Code Playgroud)
在每一页都会很痛苦.我在想,无论如何我们都可以在IIS7中设置它(将此标题添加到aspx页面,但不是image/css/js).可能吗 ?
编辑:根据http://technet.microsoft.com/en-us/library/cc753133%28WS.10%29.aspx中的建议,添加自定义http响应标头会将标头添加到所有文件,包括js,css,images .所以在这里添加"Cache-Control","no-cache"也不起作用
Edit2:我正在考虑添加一个httpmodule.类似于http://blogs.technet.com/stefan_gossner/archive/2008/03/12/iis-7-how-to-send-a-custom-server-http-header.aspx.有什么建议 ?
有没有办法在TFS中查看对存储库的修订/更改集,就像我们如何使用修订图在SVN中看到修订/分支一样?
编辑:我正在使用TortoiseSVN for SVN客户端
我使用jQuery模态对话框(jQuery UI)进行模态弹出.它工作正常,直到最近我们安装了一个activex插件.现在,当插件被激活时,这个弹出窗口就在插件后面了.有没有办法在activex插件上显示模态对话框?
浏览器:IE7,IE8
我有一个简单的HTTPModule,它可以进行一些自定义会话状态管理.
public void Init(HttpApplication context)
{
context.AcquireRequestState += new EventHandler(ProcessBeginRequest);
ActivityLogger.LogInfo( DateTime.UtcNow.ToLongTimeString() + " In Init " + HttpContext.Current.Request.Url.AbsoluteUri);
}
Run Code Online (Sandbox Code Playgroud)
和
public void ProcessBeginRequest(object sender, EventArgs e)
{
HttpApplication application = sender as HttpApplication;
ActivityLogger.LogInfo(DateTime.UtcNow.ToLongTimeString() + " In ProcessBeginRequest ");
if (application != null)
{
string requestURL = application.Context.Request.Url.ToString();
ActivityLogger.LogInfo(DateTime.UtcNow.ToLongTimeString() + " In ProcessBeginRequest " + requestURL);
}
return;
}
Run Code Online (Sandbox Code Playgroud)
当我使用断点运行此代码时,我看到即使对于静态文件(如images,js和css)也调用了此模块.有没有人经历过这个?我认为HTTP模块只是挂钩到asp.net页面的http管道中的事件.他们是否也依赖于静态资源?或者只是卡西尼?
环境:VS2008 - cassini服务器
PS:我在沙箱中尝试使用Win2k8 IIS7(有点新),并尝试将其写入日志文件(因为我们没有VS),但无法写入日志文件.我确定它的一些写权限问题.任何人都可以指向我一些资源,它告诉我如何在W2k8中运行带有IIS7的ASP.net时为目录设置写权限
Edit1:我知道使用Integrated管道可以扩展静态和托管资源的http管道 http://aspnet.4guysfromrolla.com/articles/122408-1.aspx和http://learn.iis.net/page.aspx/243/ASPNET集成与- IIS7 /
我们在生产中使用经典管道.但仍然有兴趣了解其他人的经历.
问题2:在集成模式下使用IIS7会降低性能吗?假设您有几个模块与管道连接,性能影响有多大?如果有人可以指出我做了一些基线研究,那将会很好.
我在使用CultureInfo.CurrentCulture时形成我的字符串时使用string.format
引用此博客
这只是暗示如果您经常使用CurrentCulture,可能值得将其读入私有变量而不是大量调用CultureInfo.CurrentCulture,否则您将不必要地耗尽时钟周期.
所以这个作者
var culture = CultureInfo.CurrentCulture
string.Format(culture,"{0} some format string","some args");
string.Format(culture,"{0} some format string","some other args");
Run Code Online (Sandbox Code Playgroud)
比...更好
string.Format(CultureInfo.CurrentCulture,"{0} some format string","some args");
string.Format(CultureInfo.CurrentCulture,"{0} some format string","some other args");
Run Code Online (Sandbox Code Playgroud)
根据MSDN,CultureInfo.CurrentCulture是一个属性
多次访问属性时是否存在性能损失?
我还做了一些经验分析,我的测试表明,使用局部变量比直接使用属性更昂贵.
Stopwatch watch = new Stopwatch();
int count = 100000000;
watch.Start();
for(int i=0;i<count;i++)
{
string.Format(CultureInfo.CurrentCulture, "{0} is my name", "ram");
}
watch.Stop();
//EDIT:Reset watch
watch.Reset();
Console.WriteLine(watch.Elapsed);
Console.WriteLine(watch.ElapsedMilliseconds);
Console.WriteLine(watch.ElapsedTicks);
Console.WriteLine("--------------------");
var culture = CultureInfo.CurrentCulture;
watch.Start();
for (int i=0; i < count; i++)
{ …Run Code Online (Sandbox Code Playgroud) 在TFS中,我们可以找到两个变更集之间的"比较"文件.是否可以比较2个变更集.假设将变更集"r"作为参考并将其与变更集"s"进行比较,并找到已添加/删除/删除/编辑的文件/文件夹?
我基本上有一个枚举
public enum WorkingDays
{
Monday, Tuesday, Wednesday, Thursday, Friday
}
Run Code Online (Sandbox Code Playgroud)
并且想要对输入进行比较,输入恰好是一个字符串
//note lower case
string input = "monday";
Run Code Online (Sandbox Code Playgroud)
我能想到的最好的事情是这样的
WorkingDays day = (from d in Enum.GetValues(typeof(WorkingDays)).Cast<WorkingDays>()
where d.ToString().ToLowerInvariant() == input.ToLowerInvariant()
select d).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法呢?
编辑:谢谢Aaron&Jason.但是如果解析失败怎么办?
if(Enum.IsDefined(typeof(WorkingDay),input))//cannot compare if case is different
{
WorkingDay day = (WorkingDay)Enum.Parse(typeof(WorkingDay), input, true);
Console.WriteLine(day);
}
Run Code Online (Sandbox Code Playgroud) 我在IE-8和FF-3.5.8中设置readonly属性时发布了一个早期jQuery不一致的问题,并对答案非常满意.
但我注意到如果你动态更新(任何?)DOM元素,然后查看源(使用浏览器的视图源)我发现更新的DOM元素属性保留其旧值(更新前).但是,如果使用Firebug/IE Developer工具栏,则会显示更新的DOM
示例:http://gutfullofbeer.net/readonly.html
FF3.5-View页面来源:
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js' type='text/javascript'></script>
<script>
$(function() {
$('input.readonly').attr('readonly', true);//set input with CSS class readonly to readonly
});
</script>
</head>
<body>
<input type='text' class='readonly' maxlength='20' value='Blort'>This one is read-only<br>
<input type='text' maxlength='20' value='Fish'>This one is not read-only<br>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这里第一个文本框在jQuery的document.ready方法中设置为readonly .使用浏览器查看源代码会给出一个标记
<input type='text' class='readonly' maxlength='20' value='Blort'>
Run Code Online (Sandbox Code Playgroud)
和Firebug会给出类似的东西
<input type="text" value="Blort" maxlength="20" class="readonly" readonly="">
Run Code Online (Sandbox Code Playgroud)
IE8开发人员工具栏:
<input class="readonly" type="text" maxLength="20" readOnly="readonly" value="Blort"/>
所以我的猜测是浏览器(IE8/FF3.5)在DOM事件开始之前更早地生成html源代码(在我看来是jQuery的document.ready())
有人能告诉我幕后发生的事情吗?
我在我的表中添加了一个新的GUID/Uniqueidentifier列.
ALTER TABLE table_name
ADD VersionNumber UNIQUEIDENTIFIER UNIQUE NOT NULL DEFAULT NEWSEQUENTIALID()
GO
Run Code Online (Sandbox Code Playgroud)
当表中更新记录时,我想更新此列"VersionNumber".所以我创建了一个新的触发器
CREATE TRIGGER [DBO].[TR_TABLE_NAMWE]
ON [DBO].[TABLE_NAME]
AFTER UPDATE
AS
BEGIN
UPDATE TABLE_NAME
SET VERSIONNUMBER=NEWSEQUENTIALID()
FROM TABLE_NAME D
JOIN INSERTED I ON D.ID=I.ID/* some ID which is used to join*/
END
GO
Run Code Online (Sandbox Code Playgroud)
但只是意识到NEWSEQUENTIALID()只能与CREATE TABLE或一起使用ALTER TABLE.我收到了这个错误
The newsequentialid() built-in function can only be used in a DEFAULT expression for a column of type 'uniqueidentifier' in a CREATE TABLE or ALTER TABLE statement. It cannot be …Run Code Online (Sandbox Code Playgroud) 我一直在思考这个问题.当您计划新项目/维护组织中的现有项目时,您如何选择技术(我不是在谈论Java vs .Net与PHP).
挑选最新技术的论据
采摘现场测试技术/挑选尖端技术的争论
从开发人员的角度来看,我没有理由不用一些新技术(在业余时间)弄脏手,但他/她可能仅限于开源/免费软件/开发人员版本
从组织的角度来看,它看起来像是一把双刃剑.坐在"现场测试"技术中的时间过长,优秀的人可能会离开(更不用说总会有人喜欢熟悉技术的人拒绝更新他们的知识).尝试一种非传统的方法,你冒着超出预算/时间的风险,更不用说不可预见的风险了
TL; DR
底线.您何时认为技术足够成熟以便组织可以采用?
有什么方法可以在编译时检查格式字符串吗?
例子:
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com", "cool");//this will run
Run Code Online (Sandbox Code Playgroud)
//这将给出一个异常,因为只提供了一个参数
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com");
Exception:"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
Run Code Online (Sandbox Code Playgroud)
如果格式字符串的格式不正确(即此处 1 之后缺少“}”)
Console.WriteLine("{0} is a really {1 site", "stackoverflow.com","cool");
Exception: Input string was not in a correct format.
Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
asp.net ×2
jquery ×2
tfs ×2
activex ×1
browser ×1
caching ×1
cassini ×1
changeset ×1
css ×1
dom ×1
enums ×1
guid ×1
html ×1
http-headers ×1
httpmodule ×1
ihttpmodule ×1
iis ×1
iis-7 ×1
iqueryable ×1
javascript ×1
linq ×1
modal-dialog ×1
optimization ×1
performance ×1
properties ×1
sql-server ×1
string ×1
svn ×1
triggers ×1