Search code examples
asp.netajaxcontroltoolkit

CollapsiblePanelExtender A potentially dangerous Request.Form value was detected from the client


I am encountering this error whenever the button is clicked to collapse/expand the panel. Error: CollapsiblePanelExtender A potentially dangerous Request.Form value was detected from the client.

Can someone tell me what I did wrong and what is causing this?

<asp:Button ID="Button1" runat="server" Text="Button" />
 <ajaxToolkit:CollapsiblePanelExtender 
    TargetControlID="testPanel" 
    ID="CollapsiblePanelExtender1" 
    runat="server"
    ExpandControlid="Button1"
    CollapseControlID="Button1" 
    Collapsed="False" 
    ExpandDirection="Vertical" 
    AutoCollapse="false" 
    AutoExpand="false">

</ajaxToolkit:CollapsiblePanelExtender>

<asp:Panel ID="testPanel" runat="server">
    stuff here
</asp:Panel>

Solution

  • Put validateRequest="false" in your page directive or web.config file.

    Adding Cross-Site Scripting Protection to ASP.NET

    for example if you already have:

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="MyForm.aspx.vb"  Inherits="Proj.MyForm"%>
    

    then this should become:

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="MyForm.aspx.vb" Inherits="Proj.MyForm" ValidateRequest="false"%>
    

    Note:

    If you are using .NET 4 then you will need to add requestValidationMode="2.0" to the httpRuntime configuration section of the web.config file. For example:

    <httpRuntime requestValidationMode="2.0"/>
    

    If you don't already have a httpRuntime section in the web.config file then this goes inside the section.

    Thanks