获取actionlist以将当前url发送到actionresult

时间:2013-05-22 01:00:59

标签: asp.net-mvc

我正在尝试将当前的url传递给我的actionresult但是returnUrl总是出现null

    @Html.ActionLink("Create Student", "Create", "StudentCenter", new{ returnUrl = Request.RawUrl}, new { @class = "button" })

这是控制器

public ActionResult Create(string returnUrl)
    {
        HttpCookie cookie = new HttpCookie("redirectCookie",returnUrl);
        ViewBag.Sex = new SelectList(Enum.GetNames(typeof(SchoolCup.Domain.Sex)));
        return View();
    }

1 个答案:

答案 0 :(得分:0)

我认为你必须像这样使用

@Html.ActionLink("Create Student", "Create", "StudentCenter", new{ returnUrl = Request.RawUrl.ToString()}, new { @class = "button" })

请尝试向我发送反馈

你期望的字符串是这样的“studentCenter / create”吗?