乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      使用MVC框架4

       昵稱71011036 2020-08-10

      dotnetbrowser內(nèi)置了過濾器,所謂過濾器,就是實(shí)現(xiàn)了Action前后攔截,請(qǐng)看下例:

      1、增加目錄Filters,在該目錄下增加新的過濾器PerformanceFilter,代碼如下:

       

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      public class PerformanceFilter : Filter

      {

          public override bool Before(Controller controller)

          {

              controller.Response.Write("action即將執(zhí)行,當(dāng)前時(shí)間為:" + DateTime.Now.ToString() + "<br>");

              return true;

          }

       

          public override void After(Controller controller, ActionResult result)

          {

              controller.Response.Write("<br>action執(zhí)行完畢,當(dāng)前時(shí)間為:" + DateTime.Now.ToString());

          }

      }

       

       2、在UserController.cs里加入以下代碼:

      1

      2

      3

      4

      5

      [PerformanceFilter]

      public void TestFilter()

      {

         Response.Write("action 執(zhí)行中...");

      }

       

      3、按F5,輸入以下地址,可以看到如下效果:

       

       


       

      總結(jié):您可以看到,過濾器可以在action前后執(zhí)行,注意,before方法如果返回false,那么action以及after方法都不會(huì)被執(zhí)行。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多