" />

欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解ASP.NET MVC 解析模板生成靜態(tài)頁(RazorEngine)

 更新時(shí)間:2017年03月29日 14:43:31   作者:果凍布丁喜之郎  
我們在很多項(xiàng)目開發(fā)中會(huì)常常用到頁面靜態(tài)化,本篇文章主要介紹了詳解ASP.NET MVC 解析模板生成靜態(tài)頁(RazorEngine) ,具有一定的參考價(jià)值,有興趣的可以了解一下。

簡述

Razor是ASP.NET MVC 3中新加入的技術(shù),以作為ASPX引擎的一個(gè)新的替代項(xiàng)。在早期的MVC版本中默認(rèn)使用的是ASPX模板引擎,Razor在語法上的確不錯(cuò),用起來非常方便,簡潔的語法與.NET Framework 結(jié)合,廣泛應(yīng)用于ASP.NET MVC 項(xiàng)目。

我們在很多項(xiàng)目開發(fā)中會(huì)常常用到頁面靜態(tài)化,頁面靜態(tài)化有許多方式,最常見的就是類似很多PHP CMS種使用的 標(biāo)簽替換的方式(如:帝國CMS、EcShop等),還有很多都是偽靜態(tài),偽靜態(tài)我們就不做過多解釋,通過路由或Url重寫來實(shí)現(xiàn)就可以了。Razor為我們提供了更加方便的模板解析方式,任何東西都是兩方面的,技術(shù)也是如此,Razor解析模板雖然更加方便、簡潔,但是對于模板制作人員來說也是有一定的技術(shù)要求,或者對于開發(fā)一套模板制作功能來說,考慮的要更多一些。我們不再去探究這些問題,我們更注重哪種技術(shù)更容易、更方便、更好的滿足我們項(xiàng)目的需求。

如何使用RazorEngine

今天來簡單介紹一下如何使用RazorEngine解析模板生成靜態(tài)頁面,RazorEngine它是基于微軟的Razor之上,包裝而成的一個(gè)可以使用的模板引擎。也就是說,保留了Razor的模板功能,但是使得Razor脫離于Asp.net MVC,能夠在其它應(yīng)用環(huán)境下使用,項(xiàng)目地址:RazorEngine_jb51.rar

首先我們?nèi)odeplex上下兩個(gè)需要的dll http://razorengine.codeplex.com

看到網(wǎng)上很多介紹RazorEngine的基礎(chǔ)用法的,講解的都比較詳細(xì),對于RazorEngine運(yùn)行原理很清晰,我們在這里就不重復(fù)介紹了。寫這篇文章是對于很多新手同學(xué)來說比較喜歡,基本的用法原理都能看懂,但是如何應(yīng)用到項(xiàng)目中還是有些不是很清晰,我們只講講如何在項(xiàng)目中運(yùn)用。

本文分為兩部分:第一個(gè)部分,基本的單數(shù)據(jù)模型模板解析;第二部分,面向接口的多數(shù)據(jù)模型模板解析

第一個(gè)部分 基本的單數(shù)據(jù)模型模板解析

一、我們創(chuàng)建一個(gè)MVC項(xiàng)目,并且添加上面的兩個(gè)DLL引用,然后我們新建一個(gè)簡單的文章類

public class Articles
  {
    /// <summary>
    /// 文章ID
    /// </summary>
    public int Id { get; set; }
    /// <summary>
    /// 文章標(biāo)題
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// 文章內(nèi)容
    /// </summary>
    public string Content { get; set; }
    /// <summary>
    /// 作者
    /// </summary>
    public string Author { get; set; }
    /// <summary>
    /// 發(fā)布時(shí)間
    /// </summary>
    public DateTime CreateDate { get; set; }
  }

二、我們新建一個(gè)Razor的Html模板

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>@Model.Title</title>
</head>
<body>
  <h1>@Model.Title</h1>
  <p>作者:@Model.Author - 發(fā)布時(shí)間:@Model.CreateDate</p>
  <p>@Raw(Model.Content)</p>
</body>
</html>

說明:Model就是我們的文章實(shí)體類  在MVC的試圖頁cshtml中 我們一般都是在控制器里傳遞這個(gè)實(shí)體類 然后在視圖頁中 @model Models.Articles 來接收這個(gè)實(shí)體類 然后通過“@Model.”來輸出內(nèi)容,在Razor模板中是一樣的,只是不用@model Models.Articles 來接收了,其它的語法跟在.cshtml試圖頁中是一樣的,這么說多余了,因?yàn)閷懛ú灰粯铀筒皇荝azor了

三、我們寫一個(gè)方法來獲取模板頁的Html代碼

 /// <summary>
    /// 獲取頁面的Html代碼
    /// </summary>
    /// <param name="url">模板頁面路徑</param>
    /// <param name="encoding">頁面編碼</param>
    /// <returns></returns>
    public string GetHtml(string url, System.Text.Encoding encoding)
    {
      byte[] buf = new WebClient().DownloadData(url);
      if (encoding != null) return encoding.GetString(buf);
      string html = System.Text.Encoding.UTF8.GetString(buf);
      encoding = GetEncoding(html);
      if (encoding == null || encoding == System.Text.Encoding.UTF8) return html;
      return encoding.GetString(buf);
    }

    /// <summary>
    /// 獲取頁面的編碼
    /// </summary>
    /// <param name="html">Html源碼</param>
    /// <returns></returns>
    public System.Text.Encoding GetEncoding(string html)
    {
      string pattern = @"(?i)\bcharset=(?<charset>[-a-zA-Z_0-9]+)";
      string charset = Regex.Match(html, pattern).Groups["charset"].Value;
      try { return System.Text.Encoding.GetEncoding(charset); }
      catch (ArgumentException) { return null; }
    }

四、我們寫一個(gè)方法 用于生成Html靜態(tài)頁

 /// <summary>
    /// 創(chuàng)建靜態(tài)文件
    /// </summary>
    /// <param name="result">Html代碼</param>
    /// <param name="createpath">生成路徑</param>
    /// <returns></returns>
    public bool CreateFileHtmlByTemp(string result, string createpath)
    {
      if (!string.IsNullOrEmpty(result))
      {
        if (string.IsNullOrEmpty(createpath))
        {
          createpath = "/default.html";
        }
        string filepath = createpath.Substring(createpath.LastIndexOf(@"\"));
        createpath = createpath.Substring(0, createpath.LastIndexOf(@"\"));
        if (!Directory.Exists(createpath))
        {
          Directory.CreateDirectory(createpath);
        }
        createpath = createpath + filepath;
        try
        {
          FileStream fs2 = new FileStream(createpath, FileMode.Create);
          StreamWriter sw = new StreamWriter(fs2, new System.Text.UTF8Encoding(false));//去除UTF-8 BOM
          sw.Write(result);
          sw.Close();
          fs2.Close();
          fs2.Dispose();
          return true;
        }
        catch { return false; }
      }
      return false;
    }

五、我們來寫個(gè)方法調(diào)用靜態(tài)模板,并且傳遞數(shù)據(jù)模型實(shí)體類 創(chuàng)建Html靜態(tài)頁

/// <summary>
    /// 解析模板生成靜態(tài)頁
    /// </summary>
    /// <param name="temppath">模板地址</param>
    /// <param name="path">靜態(tài)頁地址</param>
    /// <param name="t">數(shù)據(jù)模型</param>
    /// <returns></returns>
    public bool CreateStaticPage(string temppath, string path, RazorEngineTemplates.Models.Articles t)
    {
      try
      {
        //獲取模板Html
        string TemplateContent = GetHtml(temppath, System.Text.Encoding.UTF8);

        //初始化結(jié)果
        string result = string.Empty;

        //解析模板生成靜態(tài)頁Html代碼
        result = Razor.Parse(TemplateContent, t);

        //創(chuàng)建靜態(tài)文件
        return CreateFileHtmlByTemp(result, path);
      }
      catch (Exception e)
      {
        throw e;
      }
    }

好了,大功告成,是不是很簡單。

這里只是一個(gè)很簡單的應(yīng)用,沒有讀取數(shù)據(jù),也沒有列表,只有一個(gè)文章數(shù)據(jù)模型,下一部分我們將介紹 多模型模板解析,因?yàn)槭嵌嗄P?所以 生成靜態(tài)頁面的時(shí)候 就不是傳遞一個(gè)具體模型實(shí)體類 我們會(huì)用到 反射,通過反射模型屬性 獲取數(shù)據(jù),有不熟悉反射的可以提前研究一下,也可以直接看下一部分的反射代碼也很簡單的。

第二部分 面向接口的多數(shù)據(jù)模型模板解析

這一部分,我們介紹使用接口來解析模板,包括列表等多種模型解析,用到了Spring注入和反射還有接口等,有不熟悉的可以百度搜一下或者評論留言。

我們接著上面的示例,我們新建兩個(gè)類庫 一個(gè)是存放數(shù)據(jù)模型的 我們叫Domain;另外一個(gè)是接口和實(shí)現(xiàn)類的 我們叫Service,然后我們添加他們之間的引用

一、我們在Domain下創(chuàng)建幾個(gè)測試類

Articles - 文章測試類

Company - 公司測試類

Column - 欄目測試類

TemplateView - 模型解析類

   public class Articles
  {
    /// <summary>
    /// 文章ID
    /// </summary>
    public int Id { get; set; }
    /// <summary>
    /// 文章標(biāo)題
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// 文章內(nèi)容
    /// </summary>
    public string Content { get; set; }
    /// <summary>
    /// 作者
    /// </summary>
    public string Author { get; set; }
    /// <summary>
    /// 發(fā)布時(shí)間
    /// </summary>
    public DateTime CreateDate { get; set; }
  }
  public class Company
  {
    /// <summary>
    /// 公司Id
    /// </summary>
    public int Id { get; set; }
    /// <summary>
    /// 公司名稱
    /// </summary>
    public string CompanyName { get; set; }
    /// <summary>
    /// 公司電話
    /// </summary>
    public string CompanyTel { get; set; }
    /// <summary>
    /// 聯(lián)系人
    /// </summary>
    public string ContectUser { get; set; }
    /// <summary>
    /// 創(chuàng)建時(shí)間
    /// </summary>
    public DateTime CreateDate { get; set; }
  }
   public class Column
  {
    /// <summary>
    /// 欄目ID
    /// </summary>
    public int Id { get; set; }
    /// <summary>
    /// 欄目名稱
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// 文章列表
    /// </summary>

    public virtual ICollection<Articles> Articles { get; set; }
  }
   public class TemplateView
  {
    /// <summary>
    /// ID
    /// </summary>
    public int Id { get; set; }
    /// <summary>
    /// 標(biāo)題
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// 內(nèi)容
    /// </summary>
    public string Content { get; set; }
    /// <summary>
    /// 作者
    /// </summary>
    public string Author { get; set; }
    /// <summary>
    /// 時(shí)間
    /// </summary>
    public DateTime CreateDate { get; set; }    
    /// <summary>
    /// 公司名稱
    /// </summary>
    public string CompanyName { get; set; }
    /// <summary>
    /// 公司電話
    /// </summary>
    public string CompanyTel { get; set; }
    /// <summary>
    /// 聯(lián)系人
    /// </summary>
    public string ContectUser { get; set; }
    /// <summary>
    /// 文章列表
    /// </summary>
    public virtual ICollection<Articles> Articles { get; set; }
  }

二、我們在Service下創(chuàng)建一個(gè)基礎(chǔ)操作接口以及其實(shí)現(xiàn)類(里面的很多方法 比如:獲取頁面的Html代碼、獲取頁面的編碼以及創(chuàng)建靜態(tài)文件等 是沒有必要寫在接口的 這個(gè)可以寫到公用的類庫里,因?yàn)檫@里就用到這么幾個(gè)方法 所以我沒有加公用類庫 就直接寫在這里面了)

/// <summary>
  /// 基礎(chǔ)操作接口
  /// </summary>
  /// <typeparam name="T"></typeparam>
  public interface IRepository<T> where T : class
  {
    /// <summary>
    /// 解析模板生成靜態(tài)頁
    /// </summary>
    /// <param name="temppath">模板地址</param>
    /// <param name="path">靜態(tài)頁地址</param>
    /// <param name="t">數(shù)據(jù)模型</param>
    /// <returns></returns>
    bool CreateStaticPage(string temppath, string path, T t);    

    /// <summary>
    /// 獲取頁面的Html代碼
    /// </summary>
    /// <param name="url">模板頁面路徑</param>
    /// <param name="encoding">頁面編碼</param>
    /// <returns></returns>
    string GetHtml(string url, System.Text.Encoding encoding);

    /// <summary>
    /// 獲取頁面的編碼
    /// </summary>
    /// <param name="html">Html源碼</param>
    /// <returns></returns>
    System.Text.Encoding GetEncoding(string html);

    /// <summary>
    /// 創(chuàng)建靜態(tài)文件
    /// </summary>
    /// <param name="result">Html代碼</param>
    /// <param name="createpath">生成路徑</param>
    /// <returns></returns>
    bool CreateFileHtmlByTemp(string result, string createpath);
  }
/// <summary>
  /// 基礎(chǔ)接口實(shí)現(xiàn)類
  /// </summary>
  /// <typeparam name="T"></typeparam>
  public abstract class RepositoryBase<T> : IRepository<T> where T : class
  {
    /// <summary>
    /// 解析模板生成靜態(tài)頁
    /// </summary>
    /// <param name="temppath">模板地址</param>
    /// <param name="path">靜態(tài)頁地址</param>
    /// <param name="t">數(shù)據(jù)模型</param>
    /// <returns></returns>
    public bool CreateStaticPage(string temppath, string path, T t)
    {
      try
      {
        //實(shí)例化模型
        var Entity = new Domain.TemplateView();

        //獲取模板Html
        string TemplateContent = GetHtml(temppath, System.Text.Encoding.UTF8);
        //初始化結(jié)果
        string result = "";

        //反射賦值
        Type typeT = t.GetType();
        Type typeEn = Entity.GetType();

        System.Reflection.PropertyInfo[] propertyinfosT = typeT.GetProperties();

        foreach (System.Reflection.PropertyInfo propertyinfoT in propertyinfosT)
        {
          System.Reflection.PropertyInfo propertyinfoEn = typeEn.GetProperty(propertyinfoT.Name);
          if (propertyinfoEn != null && propertyinfoT.GetValue(t, null) != null)
          {
            propertyinfoEn.SetValue(Entity, propertyinfoT.GetValue(t, null), null);
          }
        }

        //很多時(shí)候 我們并沒有創(chuàng)建復(fù)雜的主外鍵關(guān)系 例如欄目下的文章 我們僅僅是在文章表中添加了一個(gè)所屬欄目ID的字段
        //并沒有創(chuàng)建關(guān)聯(lián) 這種情況下 我們直接獲取欄目的時(shí)候 是獲取不到文章列表的
        //包括很多自定義的模型和字段 比如 文章的內(nèi)容 可能不跟文章一個(gè)表 而是一個(gè)單獨(dú)的大數(shù)據(jù)字段表 這種情況下 我們的
        //TemplateView.Content就需要單獨(dú)獲取一下另一個(gè)數(shù)據(jù)模型里的 這個(gè)文章的內(nèi)容 這種時(shí)候 我們可以在這里重新給他賦值

        //如 傳入的模型是 文章
        //if(t is Domain.Articles)
        //{
        //  Entity.Content= 查詢大數(shù)據(jù)字段表中這篇文章的內(nèi)容;
          
        //}

        result = Razor.Parse(TemplateContent, Entity);

        return CreateFileHtmlByTemp(result, path);
      }
      catch (Exception e)
      {
        throw e;
      }
    }

    /// <summary>
    /// 獲取頁面的Html代碼
    /// </summary>
    /// <param name="url">模板頁面路徑</param>
    /// <param name="encoding">頁面編碼</param>
    /// <returns></returns>
    public string GetHtml(string url, System.Text.Encoding encoding)
    {
      byte[] buf = new WebClient().DownloadData(url);
      if (encoding != null) return encoding.GetString(buf);
      string html = System.Text.Encoding.UTF8.GetString(buf);
      encoding = GetEncoding(html);
      if (encoding == null || encoding == System.Text.Encoding.UTF8) return html;
      return encoding.GetString(buf);
    }

    /// <summary>
    /// 獲取頁面的編碼
    /// </summary>
    /// <param name="html">Html源碼</param>
    /// <returns></returns>
    public System.Text.Encoding GetEncoding(string html)
    {
      string pattern = @"(?i)\bcharset=(?<charset>[-a-zA-Z_0-9]+)";
      string charset = Regex.Match(html, pattern).Groups["charset"].Value;
      try { return System.Text.Encoding.GetEncoding(charset); }
      catch (ArgumentException) { return null; }
    }

    /// <summary>
    /// 創(chuàng)建靜態(tài)文件
    /// </summary>
    /// <param name="result">Html代碼</param>
    /// <param name="createpath">生成路徑</param>
    /// <returns></returns>
    public bool CreateFileHtmlByTemp(string result, string createpath)
    {
      if (!string.IsNullOrEmpty(result))
      {
        if (string.IsNullOrEmpty(createpath))
        {
          createpath = "/default.html";
        }
        string filepath = createpath.Substring(createpath.LastIndexOf(@"\"));
        createpath = createpath.Substring(0, createpath.LastIndexOf(@"\"));
        if (!Directory.Exists(createpath))
        {
          Directory.CreateDirectory(createpath);
        }
        createpath = createpath + filepath;
        try
        {
          FileStream fs2 = new FileStream(createpath, FileMode.Create);
          StreamWriter sw = new StreamWriter(fs2, new System.Text.UTF8Encoding(false));//去除UTF-8 BOM
          sw.Write(result);
          sw.Close();
          fs2.Close();
          fs2.Dispose();
          return true;
        }
        catch { return false; }
      }
      return false;
    }
  }

三、我們分別創(chuàng)建 文章管理、公司管理、欄目管理的接口和實(shí)現(xiàn)類 并且他們都集成基礎(chǔ)操作

   /// <summary>
  /// 文章管理
  /// </summary>
   public interface IArticleManage:IRepository<Domain.Articles>
  {
  }
  public class ArticleManage:RepositoryBase<Domain.Articles>,IArticleManage
  {
  }

  /// <summary>
  /// 公司管理
  /// </summary>
  public interface ICompanyManage:IRepository<Domain.Company>
  {
  }
  public class CompanyManage:RepositoryBase<Domain.Company>,ICompanyManage
  {
  }

  //欄目管理
  public interface IColumnManage:IRepository<Domain.Column>
  {
  }
  public class ColumnManage:RepositoryBase<Domain.Column>,IColumnManage
  {
  }

四、注入Xml

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
 <description>Spring注入Service,容器指向本層層封裝的接口</description>
 <object id="Service.ArticleManage" type="Service.ArticleManage,Service" singleton="false">
 </object>
 <object id="Service.ColumnManage" type="Service.ColumnManage,Service" singleton="false">
 </object>
 <object id="Service.CompanyManage" type="Service.CompanyManage,Service" singleton="false">
 </object>
</objects>

五、我們分別初始化一個(gè)文章類、一個(gè)公司類(沒有管理數(shù)據(jù)表,它下面沒有文章列表 欄目模型我就不初始化了,怎么輸出列表 大家可以參考下 欄目模板) 

  public class HomeController : Controller
  {
    /// <summary>
    /// 聲明注入接口
    /// </summary>
    public IArticleManage ArticleManage = Spring.Context.Support.ContextRegistry.GetContext().GetObject("Service.ArticleManage") as IArticleManage;
    public ICompanyManage CompanyManage = Spring.Context.Support.ContextRegistry.GetContext().GetObject("Service.CompanyManage") as ICompanyManage;
    public IColumnManage ColumnManage = Spring.Context.Support.ContextRegistry.GetContext().GetObject("Service.ColumnManage") as IColumnManage;


    public ActionResult Index()
    {
      //初始化一個(gè)文章數(shù)據(jù)模型
      var entityArticle = new Domain.Articles() { Id = 1, Title = "這里是文章標(biāo)題", Content = "<span style=\"color:red;\">這里是文章內(nèi)容</span>", Author = "張三", CreateDate = DateTime.Now };

      //初始化一個(gè)公司數(shù)據(jù)模型
      var entityCompany = new Domain.Company() { Id = 1, CompanyName = "這里是公司名稱", CompanyTel = "公司電話", ContectUser = "張三", CreateDate = DateTime.Now };

      //調(diào)用方法生成靜態(tài)頁面
      ArticleManage.CreateStaticPage(Server.MapPath("/Templates/Temp_article.html"), Server.MapPath("/Pages/news/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "1.html"), entityArticle);
      CompanyManage.CreateStaticPage(Server.MapPath("/Templates/Temp_company.html"), Server.MapPath("/Pages/news/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "2.html"), entityCompany);

      return View();
    }

    public ActionResult About()
    {
      ViewBag.Message = "Your application description page.";

      return View();
    }

    public ActionResult Contact()
    {
      ViewBag.Message = "Your contact page.";

      return View();
    }
    
  }

 六、這是測試的簡單的文章模板、公司模板和欄目模板 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>@Model.Title</title>
</head>
<body>
  <h1>@Model.Title</h1>
  <p>作者:@Model.Author - 發(fā)布時(shí)間:@Model.CreateDate</p>
  <p>@Raw(Model.Content)</p>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title></title>
</head>
<body>
  <p>公司名稱:@Model.CompanyName</p>
  <p>公司電話:@Model.CompanyTel</p>
  <p>聯(lián)系人:@Model.ContectUser</p>
  <p>創(chuàng)建時(shí)間:@Model.CreateDate</p>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title></title>
</head>
<body>
  <p>欄目標(biāo)題: @Model.Title</p>
  <p>
    文章列表
    <ul>
      @foreach(var item in @Model.Articles)
      {
      <li>
        <a href="">
          <span>@item.Title</span>
          <span>@item.Author</span>
          <span>@item.CreateDate</span>
        </a>
      </li>
      }
    </ul>
  </p>
</body>
</html>

我們運(yùn)行一下,大功告成~~~

怎么排序?怎么獲取前幾條?怎么格式化日期時(shí)間?怎么分頁?

這可是Razor啊,這都不需要再多講了吧,簡單一說,如果你傳入數(shù)據(jù)前沒有事先排序或者獲取前幾條,這些操作要做模板里操作 那跟在.cshtml里基本是一樣的

@foreach(var item in @Model.ListColumn)
{

 <div >
@if (@item.LinkUrl==null)
  {
    <ul>
@foreach(var article in @item.COM_ARTICLE.Take(15).OrderByDescending(p=>p.UpDateDate))
{

<li>
      <a href="@article.LinkUrl" rel="external nofollow" class="gd-a">
        <div>@article.Title</div></a>
      </li>
}
 </ul>
   }
  else
   {

  }
</div>
}

 應(yīng)用還是很廣泛的,而且解析代碼相對于標(biāo)簽替換來說十分簡潔、高效。有時(shí)間可以多研究研究,改天有空寫一個(gè)模板替換標(biāo)簽的供大家參考一下。有人會(huì)說那我還得教前臺(tái)制作Razor語法,這種說法我們沒法去置評,標(biāo)簽替換你仍然要教他如何使用標(biāo)簽啊,所以是不是復(fù)雜并不是探究的主題,想要前臺(tái)制作人員更方便的制作一套模板語法并不是主要因素,比如我們可以做一套方便的模板制作,用戶點(diǎn)擊一下就生成代碼,或者直接做成可視化的,這可能讓我們的程序員要耗費(fèi)更多的精力,但是一勞永逸,標(biāo)簽替換方式你仍然要給前臺(tái)制作人員一套標(biāo)簽規(guī)范和語法,況且后臺(tái)解析異常的龐大和復(fù)雜。

 以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • .NET使用StackTrace獲取方法調(diào)用信息的代碼演示

    .NET使用StackTrace獲取方法調(diào)用信息的代碼演示

    StackTrace, 位于 System.Diagnostics 命名空間下,名字很直觀,它代表一個(gè)方法調(diào)用的跟蹤堆棧,里面存放著按順序排列的棧幀對象(StackFrame),每當(dāng)發(fā)生一次調(diào)用,就會(huì)壓入一個(gè)棧幀,這篇文章主要介紹了.NET使用StackTrace獲取方法調(diào)用信息,需要的朋友可以參考下
    2022-09-09
  • asp.net core配合vue實(shí)現(xiàn)后端驗(yàn)證碼邏輯

    asp.net core配合vue實(shí)現(xiàn)后端驗(yàn)證碼邏輯

    網(wǎng)上的前端驗(yàn)證碼邏輯總感覺不安全,驗(yàn)證碼建議還是使用后端配合驗(yàn)證。本文主要介紹了asp.net core配合vue實(shí)現(xiàn)后端驗(yàn)證碼邏輯,感興趣的可以了解一下
    2021-06-06
  • ASP.NET?MVC使用異步Action的方法

    ASP.NET?MVC使用異步Action的方法

    這篇文章介紹了ASP.NET?MVC使用異步Action的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-10-10
  • ASP.NET?Core使用EF查詢數(shù)據(jù)

    ASP.NET?Core使用EF查詢數(shù)據(jù)

    這篇文章介紹了ASP.NET?Core使用EF查詢數(shù)據(jù)的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • asp.net 字符串加密解密技術(shù)

    asp.net 字符串加密解密技術(shù)

    asp.net下實(shí)現(xiàn)字符串的加密解密實(shí)現(xiàn)代碼。
    2009-03-03
  • .NetCore?MemoryCache使用詳解

    .NetCore?MemoryCache使用詳解

    這篇文章主要介紹了.NetCore?MemoryCache使用,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • dotnet?命令行工具解決方案?PomeloCli詳解

    dotnet?命令行工具解決方案?PomeloCli詳解

    我們已經(jīng)有相當(dāng)多的命令行工具實(shí)現(xiàn)或解析類庫,PomeloCli?并不是替代版本,它基于Nate?McMaster的杰出工作CommandLineUtils、DotNetCorePlugins實(shí)現(xiàn)了一整套的命令行開發(fā)、管理、維護(hù)方案,這篇文章主要介紹了dotnet命令行工具解決方案PomeloCli,需要的朋友可以參考下
    2024-05-05
  • asp.net實(shí)現(xiàn)word文檔在線預(yù)覽功能的方法

    asp.net實(shí)現(xiàn)word文檔在線預(yù)覽功能的方法

    這篇文章主要介紹了asp.net實(shí)現(xiàn)word文檔在線預(yù)覽功能的方法,可實(shí)現(xiàn)office文檔轉(zhuǎn)html,再在瀏覽器里面在線瀏覽,是非常實(shí)用的技巧,需要的朋友可以參考下
    2014-11-11
  • 簡單了解.NET Framework

    簡單了解.NET Framework

    這篇文章主要介紹了.NET Framework的相關(guān)資料,文中講解非常細(xì)致,幫助大家更好的學(xué)習(xí).NET Framework,有意向想學(xué)習(xí).NET Framework的朋友可以了解下
    2020-07-07
  • 微信公眾平臺(tái)開發(fā)之地理位置.Net代碼解析

    微信公眾平臺(tái)開發(fā)之地理位置.Net代碼解析

    這篇文章主要為大家詳細(xì)解析了微信公眾平臺(tái)開發(fā)之地理位置.Net代碼,感興趣的小伙伴們可以參考一下
    2016-06-06

最新評論