Miscellaneous: Common Mistakes 01

ylbtech - Miscellaneous: Common Mistakes 01

 

1.Back to top
1. The rich text box submits the prompt "A potentially dangerous Request.Form value was detected from the client ()."
1.1、
1.2. The method added to the API belongs to the parameter "[ValidateInput(false)] "
[ValidateInput(false)]
        [HttpPost, Route("")]
        public JsonResult Create(Information model)
        {
            Service.Insert(model);
            return Ok("");
        }
1.3. Extend ValidateInputAttribute.cs
#region 程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// D:\work-JFB\JFBWeb\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll
#endregion

namespace System.Web.Mvc
{
    // 
    // Summary:
     //      Represents an attribute used to mark an action method whose input must be validated. 
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true , AllowMultiple = false )]
     public  class ValidateInputAttribute : FilterAttribute, IAuthorizationFilter
    {
        // 
        // Summary:
         //      Initialize a new instance of the System.Web.Mvc.ValidateInputAttribute class.
        // 
        // Parameters:
         //    enableValidation:
         //      True if validation is enabled. 
        public ValidateInputAttribute( bool enableValidation );

        // 
        // Summary:
         //      Gets or sets a value indicating whether validation is enabled.
        // 
        // Return result:
         //      true if validation is enabled; otherwise, false. 
        public  bool EnableValidation { get ; }

        // 
        // Summary:
         //      Called when authorization is required.
        // 
        // Parameters:
         //    filterContext:
         //      Filter context.
        // 
        // Exception:
         //    T:System.ArgumentNullException:
         //      filterContext parameter is null. 
        public  virtual  void OnAuthorization(AuthorizationContext filterContext);
    }
}
2、
2.Back to top
 
3.Back to top
 
4.Back to top
 
5.Back to top
 
 
6.Back to top
 
7.Back to top
 
8.Back to top
 
9.Back to top
 
10.Back to top
 
 
11.Back to top
 
12.Back to top
 
13.Back to top
 
14.Back to top
 
15.Back to top
 
 
16.Back to top
 
warn Author: ylbtech
Source: http://ylbtech.cnblogs.com/
The copyright of this article belongs to the author and the blog garden. Reprints are welcome, but this statement must be retained without the author's consent, and a link to the original text should be given in an obvious position on the article page, otherwise Reserve the right to pursue legal responsibility.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324586841&siteId=291194637