我有一个UrlHelper的扩展,我将在每个页面上使用chtml.我是否有任何方法可以参考此扩展而无需使用它?
UrlExtender.cs
using System;
using System.IO;
using System.Web.Mvc;
namespace MySite.Web.MVC.Extender
{
public static class UrlExtender
{
public static string ContentLastWrite(this UrlHelper helper, string contentPath)
{
try
{
DateTime lastWriteTime = (new FileInfo(helper.RequestContext.HttpContext.Server.MapPath(contentPath))).LastWriteTime;
contentPath = string.Format("{0}?v={1:yyyyMMddHHmmss}", contentPath, lastWriteTime);
return helper.Content(contentPath);
}
catch
{
return helper.Content(contentPath);
}
}
}
}
page.chtml
@using MySite.Web.MVC.Extender
@ViewBag.Title...
我想避免在每个页面上调用“MySite.Web.MVC.Extender”“chtml”
谢谢