Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 14, 2010 05:22 PM by levib
Dec 10, 2009 06:31 AM|LINK
The constructor is too early to access the RouteData property (or any request-specific property, for that matter) on the controller. It might be better to override OnActionExecuting() and access ViewData + RouteData from there, depending on what exactly
you want to do.
Jan 14, 2010 10:41 AM|LINK
It might be better to override OnActionExecuting() and access ViewData + RouteData from there, depending on what exactly you want to do.
How do I pass the return value back to controller? This one is not right.
Public Class UserTimeCheckAttribute
Public Overloads Overrides Sub OnActionExecuting(ByVal filterContext As ActionExecutingContext)
Dim VisitController As String = filterContext.RouteData.Values("controller")
Return "User visit Controller: " & VisitController & " at Time: " & Date.Now [:(]
Public Class BaseController
Public Sub New()
Function Index() As ActionResult
ViewData("Message") = "Welcome to Asp.net MVC"
Jan 14, 2010 05:22 PM|LINK
The OnActionExecuting() method doesn't return anything. But you can access
filterContext.Controller.ViewData from within that method, so you can populate ViewData.