Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

ASP.NET - A potentially dangerous Request.Form value was detected from the client

I am using a LinkButton.  When the user clicks on the LinkButton the above error occurs.  Any way to avoid the error?  I can't put pagevalidation = false.

<asp:LinkButton ID="lnkDownloadDoc" runat="server" 
      ImageID='<%#DataBinder.Eval(Container, "dataItem.imageId")%>'
      OnClick="lnkDownloadImage_Click" >
      <%#DataBinder.Eval(Container, "dataItem.imageId")%>
</asp:LinkButton>

Open in new window


Thanks
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Could you send the contents of "DataBinder.Eval(Container, "dataItem.imageId")"?

Any way, the link button control values cannot contain the following characters: "<", ">", etc. as explained in the link below:
http://www.dreamincode.net/forums/topic/234664-potentially-dangerous-requestform-value-was-detected-from-the-client/

Possible solutions:
1) Disable validation, check:
http://stackoverflow.com/questions/9130186/a-potentially-dangerous-request-form-value-was-detected-from-the-client
2) Avoid using these characters on your html markup. Encoding (HtmlEncode) may not work because you are using these characters at ImageID.
Avatar of CipherIS

ASKER

I've attached a copy of the data being passed.  I am using a repeater.  In the repeater I have a LinkButton.  The linkbutton is useing column imageStoreID.  That field is the one causing the error.  It does not make sense why that would be the issue.  

Any ideas?
DocIDIssue.jpg
The data looks good, thus the link control is not the problem here, you have these characters elsewhere in the page that are being transmitted as part of the post back request, please post markup/code of the whole page, (e.g. lnkDownloadImage_Click)
The way I will go about it is I will start removing markup element until you find the culprit control markup causing this issue. Antoher way is to create just a new page with the repeater and the link button and see if you still have the same error.
ASKER CERTIFIED SOLUTION
Avatar of SAMIR BHOGAYTA
SAMIR BHOGAYTA
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial