Session, http, web development principles, and xss vulnerabilities in ASP. NET notes

Source: Internet
Author: User

1. Session

2. Verification Code

YZM. ashx
Copy codeThe Code is as follows:
<% @ WebHandler Language = "C #" Class = "YZM" %>

Using System;
Using System. Web;

Public class YZM: IHttpHandler, System. Web. SessionState. IRequiresSessionState
{

Public void ProcessRequest (HttpContext context ){
Context. Response. ContentType = "image/JPEG ";
Using (System. Drawing. Bitmap bitImage = new System. Drawing. Bitmap (130,100 ))
{
// Set the canvas
Using (System. Drawing. Graphics g = System. Drawing. Graphics. FromImage (bitImage ))
{

// Random Number
Random my_random = new Random ();
Int num_01 = my_random.Next (100 );
Int num_02 = my_random.Next (100 );

Int result = num_01 + num_02;
String num_string01 = num_01.ToString ();
String num_string02 = num_02.ToString ();
String result_string = result. ToString ();
// Save it to the sessionid of the server
HttpContext. Current. Session ["YZM"] = result_string;
// Set text
G. DrawString (num_string01 + "+" + num_string02 + "? ", New System. Drawing. Font (" ", 20), System. Drawing. Brushes. Red, new System. Drawing. PointF (0, 0 ));
// Save it to the output stream
BitImage. Save (context. Response. OutputStream, System. Drawing. Imaging. ImageFormat. Jpeg );
}
}
}

Public bool IsReusable {
Get {
Return false;
}
}

}

YZM. aspx
Copy codeThe Code is as follows:
<Form id = "form1" runat = "server">
<Div>
<% -- Click Refresh verification code -- %>

</Div>
<Asp: TextBox ID = "TextBox1" runat = "server" text = ""> </asp: TextBox>
<Asp: Button ID = "Button1" runat = "server" onclick = "button#click" Text = "Button"/>
</Form>

3. http protocol

4. click the button to implement the hyperlink submission form for the effect of deleting the regular expression row

5. web development principles

6. XSS vulnerabilities

Label is similar to the control: Literal control. If the value of text in the property is <a href = "www.baidu.com"> hah </a>, the link can be embedded,

You can set the mode attribute to Encode.

7. virtual directory ~ : Used in ASP.net, always starting under the application root directory

 

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.