MVC中表单的方法和操作 [英] method and action for form in MVC

查看:89
本文介绍了MVC中表单的方法和操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧的html结构中,如果有人想要反馈或来自用户的任何回复,通常他们会添加一个非常标准,比如说出你的姓名,电子邮件和评论,我们会回复你。

因此,当用户填写姓名电子邮件和评论并单击发送按钮时,信息将消失,用户会收到您的消息已发送的回复,并且将很快联系用户或获得答案。在表单标签中有类似



< form name =Form1method =Postaction =Some ISP Site> ; 





用户发送的信息在哪里?它是否像电子邮件一样发送给网站所有者?它是否位于评论表下的数据库中?过去这是由一些互联网服务提供商处理的,然后网站所有者用来收到电子邮件。



我正在使用MVC网络应用程序,我有评论表单,现在我需要做什么才能获得用户输入的数据?



我的表单功能非常完美,用户输入名称地址和评论和他/她被重定向到一个页面,它说感谢你的输入我们会回复你。



现在百万美元的问题这个数据在哪里用户输入?

解决方案

在我的文章 MVC基本站点:第1步 - 多语言站点骨架 [ ^ ]我提供了一个用户身份验证的好例子(和源代码)从头开始实施和注册机制。所以你应该在 AccountControler.Register()中看到如何处理来自 Register 视图的用户注册数据。

In the old html structure, if one wanted a feedback or any response from the user, normally they add a pretty standard from like put your name, email and comments and we get back to you.
So when the use fills in the name email and comments and clicks the send button the information disappears and the user gets a response that your message has been sent and the user will be contacted or get an answer soon. in the form tag there is like

<form name="Form1" method="Post" action="Some ISP Site ">



where is the information goes which the user has sent ? does it goes like a email message to the site owner ? does it sits in a database under a comments table ? the old days this was handled by some internet service providers address and then either the site owner use to get an email.

I am using an MVC web app where I have a comments form, now what do I need to do that I get the data back which user inputs ?

My forms functionality is perfect, the user puts in name address and comments and he/she gets redirected to a page where it say thanks for your input we will get back to you.

Now the million dollar question where is this data which user put in ?

解决方案

In my article MVC Basic Site: Step 1 – Multilingual Site Skeleton[^] I am providing a good examples (and source code) of user authentication and registration mechanisms implemented from scratch. So you should see there in AccountControler.Register() how to handle the user registration data that come from Register view.


这篇关于MVC中表单的方法和操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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