在MVC中传递数据的最佳做法 [英] Best Practises For Passing the Data in MVC

查看:50
本文介绍了在MVC中传递数据的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

将数据传递到数据库的最佳实践是什么?

是通过Formcollection还是Model?

Hi Friends,

What is the best practise for Passing the Data into the database ?

is it passing the Formcollection or Model?

[HttpPost]
public ActionResult Create(FormCollection collection)
{

}


or 

<pre lang="sql">[HttpPost]
public ActionResult Create(ModelName model)
{

}

推荐答案

将模型从视图传递到Controller,反之亦然是建议的最佳实践.

通过链接以三种不同方式实现ASP.NET MVC视图 [ ^ ]详细了解.

谢谢,
基兰(Kiran)
Passing the Model from view to Controller and vice-versa is the suggested best practice.

Go through link Implementing ASP.NET MVC Views in three different ways[^] to undersand in detail.

Thanks,
Kiran


这篇关于在MVC中传递数据的最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆