ASP. NET programming method without dragging--1th back

Source: Internet
Author: User

Previously written in the ASP. NET programs are basically written by the Webfrom control, of course, there is a benefit is easy to get started, fast and efficient, but feel themselves this a few small system, or did not learn anything, feel the bottom of the heart, because all are packaged good things, take to use, function can be realized, But the original rational things do not understand, so encountered some errors at all, although seemingly a lot of company development has controls, but as a student personally think or do not use well, of course, those custom control is another matter.

I would like to delve into ASP. NET MVC, but found that there is too much knowledge, so now for the moment to learn html+ashx this form, replaced by this form of writing is really not used, the following I learned today to record down:

Create a new project, and then set up an HTML page and ASHX general handler, in short, the client made a request with the browser's HTML page, sent to the server ashx for processing, and then ashx back to the browser in HTML form to the user, the following is the HTML code:

<form action= "Handler.ashx" method= "get" > <!--action is to specify which handler the form is to be submitted to, in two ways, one for Get and one for post--> account: <in Put type= "text" name= "account"/><br/> Password: <input type= "text" name= "password"/><br/> <select na Me= "Zhongzu" > <option value= "ren" > People </option> <option value= "Yao" > Demon </option><input type= "Submit" value= "Login" > <!--looks like only text, select, radio data can be submitted--</form>

is a login interface, and then can choose whether it is a person or demon-. -

ASHX's Code:

Using System;

Using system.collections.generic;using system.linq;using system.web;namespace ajaxlianxi{   //< summary>   //Handler Summary description    //</summary>    public class Handler:ihttphand ler    {        public void ProcessRequest (HttpContext context)         {             context. Response.ContentType = "text/html";            String account = context. request["Account"];            String password = context. request["Password"];            String Zhongzu = context. request["Zhongzu"];            if (account = = "111" && password = "222")   &nbs P         {                if (Zhongzu = = "Ren")     &N Bsp           {        &NBSp           context. Response.Write ("Hello, Human");               }                else                {            &NBS P       context. Response.Write ("Hello, Monster");               }            }            else            {        &NB Sp       context. Response.Write ("Login Failed");           }       }        public bool isreusable        {            get      &NBS P     {                return false;          &NB Sp }      &NBSP; }   }}

The results of the operation are as follows:

Click Sign In

Note The URL after login is Http://localhost:9913/Handler.ashx?account=111&password=222&zhongzu=yao
Can see the link in the form fill in the parameters, then my account password will not be visible to people? With the Post method, there is a limit to the size of the pass value, post is not qualified.

Ashx with context. request["Account"] to receive the value of accounts, and so on, and then in the if to make a judgment, the following results ~

Returns HTML results to the browser after the generic handler has been processed

The next step is to continue in-depth study of this mode, feel that the mode of the control is much more interesting, but to learn or there is a long way to go, continue to refuel

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.