asp.net mvc中的post提交方式
2011-08-09 23:35
260 查看
asp.net中 mvc的post方式提交也其他普通的提交没有什么大区别,只不过多了自己点特色
页面html表单类似这样:
<form action="http://test.com/edit" method="post">
id:<input name="id" type="text" />
<input type="submit" value="submit">
</form>
mvc代码有两个方式
1.在路由中配置url路径,类似http://test.com/edit
然后在controller类的action方法中
[HttpPost]
public ActionResult Edit()
{
tring temp = Request.Form["id"];//html表单中的控件的name值
......
}
2.第二种方式,是在路由配置详细的路径
路由中类似这样"edit/{id}/{name}"
把参数定义在路由映射中,参数的名称就是表单中控件名称
这样就可以在controller类中的action方法中这样写
[HttpPost]
public ActionResult Edit(string id,string name)
{
//string temp = Request.Form["id"];
return View();
}
方法的参数就是html表单中的参数
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。
页面html表单类似这样:
<form action="http://test.com/edit" method="post">
id:<input name="id" type="text" />
<input type="submit" value="submit">
</form>
mvc代码有两个方式
1.在路由中配置url路径,类似http://test.com/edit
然后在controller类的action方法中
[HttpPost]
public ActionResult Edit()
{
tring temp = Request.Form["id"];//html表单中的控件的name值
......
}
2.第二种方式,是在路由配置详细的路径
路由中类似这样"edit/{id}/{name}"
把参数定义在路由映射中,参数的名称就是表单中控件名称
这样就可以在controller类中的action方法中这样写
[HttpPost]
public ActionResult Edit(string id,string name)
{
//string temp = Request.Form["id"];
return View();
}
方法的参数就是html表单中的参数
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。
相关文章推荐
- Asp.net MVC中防止HttpPost重复提交
- asp.net mvc 在 post 和 get 方式下的 ModelBinder
- ASP.NET MVC post提交表单 后台值为空
- ASP.NET Post方式提交
- Asp.net MVC中防止HttpPost重复提交
- ASP.NET MVC下Ajax.BeginForm方式无刷新提交表单实例
- Asp.net Mvc post表单提交多个实体模型
- ASP.NET POST方式提交数据!
- ASP.NET MVC,深入浅出IModelBinder,在Post方式下慎用HtmlHelper
- ASP.NET MVC 表单的几种提交方式
- ASP.NET POST方式提交数据
- asp.net中用来进行Post和Get方式提交表单的方法
- ASP.NET MVC,深入浅出IModelBinder,在Post方式下慎用HtmlHelper
- 在ASP.NET MVC中以post方式传递数组参数的示例
- asp.net页面的提交方式POST和GET 区别
- 【转】ASP.NET中GET与POST提交方式的区别
- Asp.net的post提交方式
- 艾伟:ASP.NET MVC,深入浅出IModelBinder,在Post方式下慎用HtmlHelper
- asp.net 数据提交中的GET,POST, PUT,DELETE,四种方式
- ASP.NET MVC实现POST方式的Redirect