I have an UrlHelper extension, I will use chtml on every page. Do I have a way to reference this extension without having to do this with?
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 <!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> <link href="@Url.ContentLastWrite("~/Content/Site.css")" rel="stylesheet" type="text/css" /> ...
I want to avoid calling "MySite.Web.MVC.Extender" on each "chtml" page
thanks
source share