From a page I have the following:
@using (Html.BeginForm("AddEntry", "Configure", FormMethod.Get, new { returnUrl = this.Request.RawUrl }))
{
@Html.TextBox("IP")
@Html.Hidden("TypeId", 1)
<input type="submit" value="@Resource.ButtonTitleAddComponent" />
}
so controller is called correctly:
public ActionResult AddEntry(string ip, int TypeId, string returnUrl)
{
// Do some stuff
return Redirect(returnUrl);
}
My problem is that returnUrl gets null and it does not redirect to the same page that called the controller. Ideas?
Using: ASP.NET MVC 4 Razor
You could use a Request.QueryString
method to get some values from URL, for sample:
@using (Html.BeginForm("AddEntry", "Configure", FormMethod.Get, null))
{
@Html.TextBox("ip")
@Html.Hidden("TypeId", 1)
@Html.Hidden("returnUrl", this.Request.RawUrl)
<input type="submit" value="@Resource.ButtonTitleAddComponent" />
}
And in your controller, receive it as a parameter string returnUrl
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments