登录转发页面URL有太多信息

时间:2015-01-21 20:25:35

标签: javascript c# asp.net-mvc url-routing

在我的MVC应用程序中,我自己处理所有登录/身份验证/等,并遇到了问题。当用户直接访问页面而不登录时,我使用LoginForward控制器操作处理它。这正是我正在做的事情:

在许多不同的控制器操作(C#)中:

if (login == null)
    return RedirectToAction("LoginForward", "Account", 
        new ForwardViewModel { 
            ForwardToController = "Admin", 
            ForwardToAction = "ProxyMaint", 
            ForwardToID = id 
        });

LoginForward Action(C#):

public ActionResult LoginForward(string ForwardToController, string ForwardToAction, int ForwardToID)
{
    return View(new ForwardViewModel
    {
        CurrentUserID = -1,
        ForwardToController = ForwardToController,
        ForwardToAction = ForwardToAction,
        ForwardToID = ForwardToID
    });
}

在我的视图中,在验证登录后,我正在执行此操作(javascript):

window.location.href = '@((Model.ForwardToID == -1) ? 
    Url.Action(Model.ForwardToAction, Model.ForwardToController) : 
    Url.Action(Model.ForwardToAction, Model.ForwardToController, new { 
        id = Model.ForwardToID 
    }))';

我看到的问题是该视图有一个如下所示的网址:

http://localhost:66666/Account/LoginForward?ForwardToController=MyController&ForwardToAction=MyAction&ForwardToID=12345&CurrentUserID=0&CanAccessOpenItems=False&IsAdmin=False&CanAccessAnyReports=False&CanAccessAnyAdmin=False

有没有办法让我不在网址中包含所有这些数据?

0 个答案:

没有答案