On the security of ASP.net MVC application--Practical skills

Source: Internet
Author: User

To protect the security of Web applications it seems like time is hard work, and this must do not bring much fun, but in order to avoid embarrassing security vulnerabilities, the security of the program usually has to do.

1. asp.net Web Forms Developer

(1) Because ASP.net MVC does not provide many automatic protection mechanisms to protect a page from malicious users, as ASP.net Web Forms do, read this blog to understand the problem, and more specifically: asp.net Web Forms is dedicated to keeping applications from attack. For example:

1 The server component HTML encodes the displayed values and attributes to help prevent XSS attacks.

2) Encrypt and verify the attempted state to help prevent tampering with the submitted form.

3 Request verification (% @page validaterequest= "true") intercepts seemingly malicious data and warns (this is the protection that the MVC Framework defaults on).

4 event validation helps the organization inject attacks and commit invalid values.

(2) Turning to ASP.net mvc means that the processing of these problems will fall on the programmer's shoulders-which may cause panic for some people and may be a good thing for others.

(3) If you think that the framework "should handle this kind of thing", then there is a framework that can handle this kind of thing, and handle it very well, it is asp.net Web forms. The price, however, is the loss of some control over the abstraction level introduced into the ASP.net web froms.

(4) asp.net MVC provides more control over markup, which means that the programmer has to assume more responsibility, and it is clear that asp.net MVC provides many built-in protection mechanisms such as HTML encoding and request validation by default using HTML helper methods and razor syntax )。

2.asp.net MVC Developer

(1) For applications with security risks, the main excuse is that developers lack enough information or understanding that we want to change the situation, but we also realize that nobody is perfect and there is always a time for negligence. In view of this, please remember the following tips.

1 never trust any data provided by the user

2 when rendering data introduced as user input, HTML-encode it (if the data is displayed as an attribute value, it should be encoded in HTML)

3 Consider those parts of the site that allow anonymous access, and those parts require authenticated access.

4 Do not try to purify the user's HTML input yourself-otherwise you will encounter failure.

5 Use the Http-only cookie when you do not need to access cookies through client script.

6) It is highly recommended to use the ANTIXSS Library (Www.codeplex.com/AntiXSS).

(2) At the same time, the application builds on the assumption that only specific users can perform certain operations, and other users cannot.


Note: The following is an introduction to using the security features in ASP.net MVC to perform application functions such as authorization, and then describes how to handle common security threats.

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.