C# Asp.NETMVC4表单字段作为Url ID
我有一个搜索表单的方法:使用asp.NETMVC4 这是我的表格: 我的行动是: 假装我的控制器名为Stackoverflow,我的行动问题我需要url: localhost:port/Stackoverflow/Questions/id[输入值]C# Asp.NETMVC4表单字段作为Url ID,c#,asp.net-mvc,asp.net-mvc-4,C#,Asp.net Mvc,Asp.net Mvc 4,我有一个搜索表单的方法:使用asp.NETMVC4 这是我的表格: 我的行动是: 假装我的控制器名为Stackoverflow,我的行动问题我需要url: localhost:port/Stackoverflow/Questions/id[输入值] localhost:port/Stackoverflow/Questions/MVC因为您的表单没有使用模型,所以需要在get操作上从HttpContext读取ID [HttpGet] public ActionResult Questions(st
localhost:port/Stackoverflow/Questions/MVC因为您的表单没有使用模型,所以需要在get操作上从HttpContext读取ID
[HttpGet]
public ActionResult Questions(string id)
{
string _id = Request.Form["id"];
}
此时,您可能希望使用您的id重定向
return RedirectToAction("DoSomethingWithId", _id);
public ActionResult Questions(string id)
{
...
}
[HttpGet]
public ActionResult Questions(string id)
{
string _id = Request.Form["id"];
}
return RedirectToAction("DoSomethingWithId", _id);