Scan code registration and logon functions on the PC end using. NET WeChat

Source: Internet
Author: User
Tags openid
This article mainly introduces. NET development of PC terminal scan code registration and login function implementation related information, very good, has reference value, need friends can refer to the next article mainly introduced. NET development of PC terminal scan code registration and login function implementation of relevant information, very good, has reference value, need friends can refer to the next

I. Preface

The focus of this article is the implementation idea. the code and database design mainly aims to demonstrate the idea. if there are strict code efficiency requirements, do not copy them.

I believe that developers have never done this much, but we generally do more authorization for mobile websites. Specifically, it is an authorization for terminals. One problem encountered today is that the project support end and PC end are available for registration. It is required that you can log on to another terminal either after registration on the PC or after registration on the client. That is to say, no matter the PC or you have to "you are you" (in some way ).

2. find a solution

In the traditional way, users can register through Authorization. However, on the PC side, the traditional method is to fill in the mobile phone number or Email. If you use this method for registration, the following problems will occur:

1. I first authorize registration on the client. if I want to log on to the PC, I still have to register.

This solution can be: "forced" after authorization registration requires the user to fill in basic information, such as mobile phone number, Email. In this way, we can generate a PC-based logon account and password for the user, for example, using the user's nick name as the account, the mobile phone number as the password, and so on.

Disadvantages: poor user experience and security risks. After all, your nickname, Email or mobile phone number are exposed.

2. if I register on the PC, how can I associate the mobile terminal with the mobile terminal during authorization?

Of course, there will always be solutions to all problems. The idea is as follows:

Solution 1: After a user registers on the PC, the "force" user must enter a nickname. This serves as an association condition for authorization. Unfortunately, the nickname can be changed. how can it be used for association instead of the only one? Solution 1 was killed.

Solution 2: After authorization on the terminal and after registration on the PC end, users are required to enter the mobile phone number for this association. In this way, a problem arises, and it is necessary to ensure that the user's mobile phone's real information is correct. This can be achieved through the mobile phone verification code (the same is true for Email ). However, assume that the following situations exist: If I have two mobile phone numbers, enter one for PC registration and the other for registration. Is it associated? The answer is sorry. In addition, after I register on the PC end, I just leave it blank (the reason why I forcibly add double quotation marks), and then I use Terminal authorization to log on. Well, there will be two pieces of data waiting for you to find a way to associate, typical developer self-mining. This method works to some extent, but it is not acceptable to developers to be rigorous.

III. Solution to regression origin

Analysis: since there are problems with the above solutions, we should first put them aside. Sort out our ideas and let us go back to the root of the problem. Association issues require a unique identifier. The unique ID is like our ID card number. when we handle a credit card, the ID card is required. if you purchase a number card under the real name system, the ID card is required. If we are the system administrator, I can use your ID card number to find your mobile phone number and bank card number.

Background code on the logon page

Public ActionResult Login () {// if you have logged on, go directly to the homepage if (User. identity. isAuthenticated) return RedirectToAction ("Index", "Home"); string url = Request. url. host; string uuid = Guid. newGuid (). toString (); ViewBag. url = "http: //" + url + "/home/loginfor? Uuid = "+ uuid; // Construct authorization link ViewBag. uuid = uuid; // save uuidreturn View ();}

The jquery. qrcode. js plug-in is used to generate the QR code. For more information, see Github. Note that this plug-in can be used to generate two-dimensional codes. for canvas or table, you must specify table generation by using IE.

The code is as follows:

jQuery('#qrcode').qrcode({render : "table",text : "http://baidu.com"});

Return to the question. the main code on the logon page is as follows:

 

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.