In fact, we usually encounter the request way nothing but get/post, but there are many web developers are still not clear about the two.
Get is through the URL of the querystring to the server side of the way, its data is visible, can post is through a POSTDATA packet to the server, post can send more data (such as uploading files), but also more secure (such as login).
This article will demonstrate a variety of ways to submit requests to controller through the client page, which is the resulting page, and to accept them in controller.
Conventions
All of the examples in this article will be to demonstrate a login process, but do not pay attention to the judgment process, so the judgment aspect only does simple if operation.
and the submitting entity we create a new account class.
Its contents are as follows:
1: /// <summary>
2: /// 用户账户的实体类
3: /// </summary>
4: public class Account {
5: /// <summary>
6: /// 用户名
7: /// </summary>
8: public string UserName { get; set; }
9: /// <summary>
10: /// 密码
11: /// </summary>
12: public string Password { get; set; }
13: }
Most examples in this article use the account class, but not all of the examples use account.
In the text we are not concerned about the controller of the page submitting the information, only the controller of the processing information.
In controller, there is a way to assist in judgment:
1: /// <summary>
2: /// 一个辅助判断的方法
3: /// </summary>
4: /// <param name="userName">用户名 </param>
5: /// <param name="password">密码 </param>
6: /// <returns></returns>
7: string AreEquals(string userName,string password)
8: {
9: return (userName.ToLower() == "admin" && password == "123456").ToString();
10: }