locked
From Preview 2 to Preview 3 RRS feed

  • Question

  • User-2014110218 posted
    About ActionFilterAttribute, the following code is not working anymore.

    1    public class LoggedInUserOnly : ActionFilterAttribute
    2 {
    3 public override void OnActionExecuting(FilterExecutingContext filterContext)
    4 {
    5 if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
    6 {
    7 ...

    How do I need to change it?

    EDIT: I found the solution, FilterExecutingContext is now ActionExecutingContext
     

     

     

    About RedirectToAction, this:

    1    RedirectToAction(new RouteValueDictionary(new { Controller = "MyController", Action= "MyAction" Id = MyID }));

     
     becomes this?

    1    return RedirectToAction("MyAction", new RouteValueDictionary(new { Controller = "MyController", Id = MyID }));
     
    Wednesday, May 28, 2008 5:36 AM

Answers

  • User-109060882 posted

    For the second part, you could also use this shorter syntax:

    return RedirectToAction("MyAction", new { Controller = "MyController", Id = MyID });

    And we'll build up the dictionary for you.

    Thanks,

    Eilon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 28, 2008 1:24 PM