修改System.Web.Mvc.WebViewPage创建自己的pageBase
<system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="MvcApplication1.PageBase"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization"/> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web.webPages.razor>
namespace MvcApplication1 { public class PageBase<T> : System.Web.Mvc.WebViewPage<T> { public string Msg() { return "테스트 합니다."; } public override void Execute() { // throw new NotImplementedException(); } } }
<p>pageBase:@Msg() </p>