重定向链接OnActionExecuting(ActionExecutingContext)

时间:2015-09-21 09:36:22

标签: c# asp.net .net asp.net-mvc sharepoint

Salaamun Alekum 我想改写

Controller.OnActionExecuting Method (ActionExecutingContext)

在这个方法中,我想重定向到WebPage链接如何使其成为可能

示例:

public class LicenseFilterAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        ///Some Code Here
        Redirect("http://webpage.com"); ///Redirect to This Page 
        ///Rest Of The Code

如果您需要更多详细信息,请告诉我

1 个答案:

答案 0 :(得分:1)

你很接近,而不是重定向尝试

filterContext.Result = new RedirectResult("http://www.webpage.com");

这就是我用的东西。通常它会重定向到我的登录页面,该页面将在同一个项目中,所以我会做类似的事情

filterContext.Result = new RedirectResult(Url.Action("Index", "Login"));

编辑:删除了返回语句,这是一个空白,你只需要设置重定向结果而不是返回它