AllowHtml not working

后端 未结 4 2105
难免孤独
难免孤独 2021-01-03 00:01

I\'m building a Content Management System to allow people other than me to update stuff on the site.

I have a front-facing HTML form that sends data, via AJAX, to a

4条回答
  •  日久生厌
    2021-01-03 00:49

    You should do it as-

    Create a separate class with entities those are required-

    public class EntityDto {
            public String id { get; set; }
            [AllowHtml]
            public String HTML_Stuff { get; set; }
    }
    

    And then use it in your controller method-

    [ValidateInput(false)]
    public void UpdateCar(EntityDto model)
    {
        var html_stuff = model.HTML_Stuff; 
    
        // sanitation and validation
    
        String Select = String.Format("UPDATE Car Set HTML_Stuff = {0} WHERE id = {1}", html_stuff , id);
    
        // Execute DB Command
    }
    

    Let me know if it helps.

提交回复
热议问题