asp.net mvc key Tutorial first-year tenth request controller

Source: Internet
Author: User

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: }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.