开发者

I am passing a Controller as a parameter, can't get to RedirectToAction method?

开发者 https://www.devze.com 2023-01-03 07:53 出处:网络
My method looks like: public static RedirectToResult(Controller controller, ...) { } when I do: controller.

My method looks like:

public static RedirectToResult(Controller controller, ...)
{

}

when I do:

controller.

I don't see RedirectToAction, how come?

I get RedirectToAction from within 开发者_如何学运维the controller's action, but not when I pass the controller as a parameter to another classes method. Why? really confused!


RedirectToAction is a protected function. You can only call it from inside the controller class.


If you're looking for an extension method you need the 'this' keyword before the type.

    public static ActionResult RedirectToResult(this Controller controller)
    {

    }

Hope this helps


You could try out T4MVC. It will definitely help in making strongly typed Url helpers.

0

精彩评论

暂无评论...
验证码 换一张
取 消