Razor 템 플 릿 엔진 소개

1.도구 다운로드:
프로그램 다운로드 주소:링크:http://pan.baidu.com/s/1hsGJV5y비밀번호:pfja
visual studio 2015 프로그램 집합 다운로드 주소:링크:http://pan.baidu.com/s/1nvn31IL비밀번호:4v7h
VS 2015 등 더 높 은 버 전 을 사용 할 때"File not Found Exception Cannot Load System.Web.Razor.dll Version=2.0.0"과 같은 오류 가 발생 하면 다음 첨부 파일 의 프로그램 집합 으로 오래된 Razor Egine.dll 을 삭제 한 다음 Razor Engine.NET 4.0.dll 과 System.Web.Razor.Net 4.0.dll 을 항목 참조 에 추가 하 십시오. 
2.핵심 코드 패키지:

public static string ParseRazor(HttpContext context,
   string csHtmlVirtualPath, object model = null)
  {
   string fullpath = context.Server.MapPath(csHtmlVirtualPath);//            
   string cshtml = File.ReadAllText(fullpath); //   cshtml      
   string cacheName = fullpath + File.GetLastWriteTime(fullpath);//                   。
   string html = Razor.Parse(cshtml, model, cacheName);
   return html;
  }
  /// <summary>
  ///       cshtml      ,        
  /// </summary>
  /// <param name="context"></param>
  /// <param name="csHtmlVirtualPath"></param>
  /// <param name="model"></param>
  public static void OutputRazor(HttpContext context,
   string csHtmlVirtualPath, object model = null)
  {
   string html = ParseRazor(context, csHtmlVirtualPath, model);
   context.Response.Write(html);    
  }  
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기