只是想知道是否有人知道我的过滤器订单被忽略的原因...
[AcceptVerbs(HttpVerbs.Get)]
[Compress(Order = 1)]
[EnhancedOutputCache(Order = 2, Duration = 5, VaryByParam = "true", Location = OutputCacheLocation.ServerAndClient)]
public virtual ActionResult Index()
{
return View();
}
public class CompressAttribute : ActionFilterAttribute
{
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
}
}
public class EnhancedOutputCacheAttribute : OutputCacheAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
base.OnResultExecuting(filterContext);
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,EnhancedRutputCache正在Compress运行之前运行...我希望压缩首先发生但是它正在运行第二...任何想法为什么
作为旁注,我正在使用ASP.Net MVC 2.0预览1 ...
我可以使用Visual Studio 2008中的" 复制网站"工具将MVC应用程序部署到我的托管服务器吗?但是,Web站点菜单甚至没有显示在Visual Studio中,而MVC项目已打开.部署MVC应用程序的最佳实践是什么?谢谢.
.net deployment asp.net-mvc visual-studio-2008 visual-studio
控制器:
DateTime startDate = DateTime.Now;
ViewData["now"] = startDate.ToString();
ViewData["interval"] = interval.ToString();
startDate.AddMonths(interval);
ViewData["later"] = startDate.ToString();
Run Code Online (Sandbox Code Playgroud)
视图:
Now: <%=ViewData["now"] %><br />
Later: <%=ViewData["later"] %><br />
Interval: <%=ViewData["interval"] %>
Run Code Online (Sandbox Code Playgroud)
这会产生:
Now: 10/2/2009 12:17:14 PM
Later: 10/2/2009 12:17:14 PM
Interval: 6
Run Code Online (Sandbox Code Playgroud) 在限制中编码属性可以得到什么值的正确(和最好)方法是什么?
例如,假设我有以下简单类:
Public Class MyClass
Public Property MyDate As Date
Run Code Online (Sandbox Code Playgroud)
现在,假设MyDate在运行时设置,但不能采用不到一年前的任何值.
在MyDate的setter中抛出一个异常,然后在我的主模块中以一种Try...Catch方式对它进行编程是正确的,然后警告用户该值是否错误或有更好的方法吗?
我确定这是一个非常简单的问题,但我只是想确保我按照最佳编程实践来做这件事.
我想将代码添加到我的Onload处理程序但不确定它在MVC应用程序中的位置?
// You may want to place these lines inside an onload handler
CFInstall.check({
mode: "overlay",
destination: "http://localhost:1414/"
});
});
Run Code Online (Sandbox Code Playgroud)
上面的代码需要放在onload处理程序中.
我有一个包含多个XML标签的文件,如下所示:
<Good>Yay!</Good>
<Great>Yup!</Great>
<Bad>booo</Bad>
<Bad>
<Ok>not that great</ok>
</Bad>
<Good>Wheee!</Good>
Run Code Online (Sandbox Code Playgroud)
我想摆脱"坏"标签和其他任何东西.所以它会变成:
<Good>Yay!</Good>
<Great>Yup!</Great>
<Good>Wheee!</Good>
Run Code Online (Sandbox Code Playgroud)
我知道这个单行:
perl -pe "undef $/;s/<Bad>.*?<\/Bad>//msg" < originalFile > newlyStrippedFile
Run Code Online (Sandbox Code Playgroud)
似乎做我想做的一切(除了添加额外的换行符,但希望我能够轻松地处理它)
但是我需要把它放在一个脚本中(两个文件被读入命令行,一个带有所有标签,另一个带有要拔出的标签列表),所以同样的事情会被多次调用.
而我只是遇到了麻烦.要么它只读一行,要么我得错误或两者兼而有之.
以下是我最近尝试的相关部分:
open ORIGINAL_FILE, $sdb_pathname
or die "Can't open '$sdb_pathname' : $!";
@sdb_input_array = <ORIGINAL_FILE>;
close ORIGINAL_FILE;
@sdb_input_scalar=join("",@sdb_input_array);
foreach $tag (@tags) {
&remove_tag($tag);
}
sub remove_tag
{
my($current_tag) = @_;
$sdb_input_scalar =~ s/<$current_tag>.*?<\/$current_tag>//msg;
open NEWLY_STRIPPED_FILE, $clean_sdb_pathname
or die "Can't open '$clean_sdb_pathname' : $!";
print(NEWLY_STRIPPED_FILE $sdb_input_scalar);
close(NEWLY_STRIPPED_FILE);
}
Run Code Online (Sandbox Code Playgroud)
这让我"在我的$ sdb_input_scalar =〜行中使用未初始化的值$ sdb_input_scalar替换(s ///).并且仅为输入打开Filehandle NEWLY_STRIPPED_FILE
当然,我的两个文件看起来仍然相同,好像我没有对他们做任何事情. …
我正在创建一个月的日期列表.我想知道什么会更有效率
List<DateTime> GetDates(DateTime StartDay) {
List<DateTime> dates = new List<DateTime>();
int TotalDays=StartDay.AddMonths(1).AddDays(-1).Day;
for (int i=1; i<TotalDays; i++) {
dates.Add(new DateTime(StartDay.Year, StartDay.Month, i));
}
return dates;
}
Run Code Online (Sandbox Code Playgroud)
要么
List<DateTime> GetDates(DateTime StartDay) {
List<DateTime> dates = new List<DateTime>();
DateTime NextMonth = StartDay.AddMonths(1);
for (DateTime curr=StartDay; !curr.Equals(NextMonth); curr=curr.AddDays(1)) {
dates.Add(curr);
}
return dates;
}
Run Code Online (Sandbox Code Playgroud)
基本上,新的DateTime()或DateTime.addDays更有效率.
更新:
static void Main(string[] args) {
System.Diagnostics.Stopwatch sw=new System.Diagnostics.Stopwatch();
long t1, t2, total;
List<DateTime> l;
DateTime begin = DateTime.Now;
total = 0L;
for (int i=0; i<10; i++) { …Run Code Online (Sandbox Code Playgroud) 我想像在asp.net中一样在mvc中创建index.aspx.cs文件.
有人可以告诉我这个过程吗?
我的文件夹中有一些文件"~Content/Documents",其中包含每个上传的文件。就我而言,用户只能上传一个文件。
我已经完成了上传部分,用户可以上传他的文件。
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var fullpath = System.Web.HttpContext.Current.Server.MapPath("~/Content/Documents");
file.SaveAs(Path.Combine(fullpath,"document"+Path.GetExtension(fileName)));
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:用户可以上传任一".doc", ".docx", ".xls", ".xlsx", or ".pdf"格式的文件。现在,当用户上传格式文件时,".doc"它会上传到该文件夹。稍后,同一用户可以上传该".pdf"格式的文件,该文件也会上传到该文件夹。这意味着用户可以上传两个文件。
现在我想做的是:
当特定用户上传他的文档时:
->搜索该用户上传的文档是否在该文件夹中。即具有不同扩展名的特定文件名是否存在。
->如果文件名已存在且具有不同的扩展名,则删除该文件并上传新文件。
在我的急剧程序中,我有5个项目在队列中.从0 1 2 4.
当用户按下按钮我想改变项目的位置就像
第一项应该是1而最后一项应该变为0.
这就像1 2 3 4 0再次2 3 4 0 1.
我怎么能这样做?
asp.net-mvc ×6
c# ×6
.net ×5
datetime ×2
asp.net ×1
deployment ×1
onload ×1
performance ×1
perl ×1
razor ×1
regex ×1
replace ×1
stopwatch ×1
vb.net ×1