作者在 2016-11-17 16:11:29 发布以下内容
是按 New、Initialize、OnActionExecuting、具体的某个Action、OnActionExecuted 的顺序执行,的如下面代码所示:
Imports System.Web.Mvc
Public Class DefaultController
Inherits Controller
Public Sub New()
End Sub
Protected Overrides Sub Initialize(requestContext As RequestContext)
MyBase.Initialize(requestContext)
End Sub
Protected Overrides Sub OnActionExecuting(filterContext As ActionExecutingContext)
MyBase.OnActionExecuting(filterContext)
End Sub
Public Function 具体的某个Action() As ActionResult
Return Content("具体的某个Aciton")
End Function
Protected Overrides Sub OnActionExecuted(filterContext As ActionExecutedContext)
MyBase.OnActionExecuted(filterContext)
End Sub
End Class
在页面加载前处理cookies可以在Initialize里面,也可以在OnActionExecuting里面,比如进行权限验证,目前还不知道这二者的区别。