我想在Razor中指定(在一个地方)默认布局页面,以便我可以删除它:
@{ LayoutPage = "~/Views/Shared/_Layout.cshtml"; }
Run Code Online (Sandbox Code Playgroud)
从我的每个.cshtml文件.但我不知道怎么......有什么想法吗?我正在使用ASP.NET MVC 3 Preview 1中的Razor引擎.
当我在不到2-3分钟内刷新我的网站时,Firebug会显示这些不错的请求:
1. /core.css 304 Not modified
2. /core.js 304 Not modified
3. /background.jpg 304 Not modified
Run Code Online (Sandbox Code Playgroud)
但是当我在> 3分钟后刷新时,我得到:
1. /core.css 200 OK
2. /core.js 200 OK
3. /background.jpg 304 Not modified
Run Code Online (Sandbox Code Playgroud)
为什么我的CSS和JS文件再次下载而图像不是?
我正在使用ASP.NET MVC 3,我不使用[OutputCache],并且在我的/Content文件夹中(所有css,js和img文件都存在于子文件夹中)我有这个Web.config:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
它Cache-Control: max-age=86400仅设置HTTP标头.所以基本上CSS,JS和图像都以同样的方式处理,但不知何故CSS和JS不会被缓存更长时间......为什么会这样?
我创建了自己的上下文,它继承自DbContext.假设我在数据库的[Posts]表中有1个帖子.考虑这种情况:
每次刷新我的网站时,我都会查看SQL事件探查器和数据库IS,那么为什么返回的帖子有旧值?我猜DbContext试图变得非常聪明并且有一些内部缓存机制,但很高兴告诉我他很聪明......
谁可以给我解释一下这个?
我有一个字符串,我想检查它是否代表一个合适的命名空间,例如.没问题System.IO,但事实System.Lol并非如此.
我想应该使用一些反思,但我无法弄清楚这一点.
有什么想法吗?
好的,我放弃了......
我想要的是每个请求共享EF4的DbContext实例.我像这样配置了StructureMap:
For<MyContext>().Use(new MyContext("LocalhostConnString"));
Run Code Online (Sandbox Code Playgroud)
但是当我刷新我的网站,或者甚至在另一个浏览器中打开它时,我得到了与 MyContext 完全相同的实例.为什么这些请求共享?
我错过了什么吗?
我的ExceptionValidationRuleTextBox上有一个:
<Window.Resources>
<Style x:Key="textStyleTextBox" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<TextBox x:Name="myTextBox"
{Binding Path=MyProperty, ValidatesOnExceptions=True}"
Style="{StaticResource ResourceKey=textStyleTextBox}" />
Run Code Online (Sandbox Code Playgroud)
和MyProperty看起来像这样:
private int myProperty;
public int MyProperty
{
get { return myProperty; }
set
{
if(value > 10)
throw new ArgumentException("LOL that's an error");
myProperty = value;
}
}
Run Code Online (Sandbox Code Playgroud)
在DEBUG模式下,应用程序崩溃时出现未处理的异常"LOL that's an error"(WPF绑定引擎没有抓住这个,我认为它应该......).
在RELEASE模式中,一切正常.
有人能告诉我,为什么会发生这种情况?我该如何解决这个问题?
.net ×1
asp.net-mvc ×1
c# ×1
caching ×1
debugging ×1
exception ×1
namespaces ×1
razor ×1
structuremap ×1
validation ×1
wpf ×1