views:

12

answers:

1

Hi, I have the same problem as posted here

I have a <button> element that triggers "A potentially dangerous request.form value..." error in asp.net MVC. For instance:

<button type="submit" name="logon" value="ok">Confirm</button>
<button type="submit" name="cancel" value="ok">Cancel</button>

And this javascript (with jquery UI 1.8.5)

<script type="text/javascript">
    $(document).ready(function() {
        $("button").button();
    });        
</script>

The issue is that I can't remove the name property (as the given solution in the link I posted) because I capture which button is pressed in the controller side this way:

public ActionResult Logon(FormCollection form, string logon, string cancel)
{
    if (!string.IsNullOrEmpty(logon))
    {
        DoLogon(); 
    }

    if (!string.IsNullOrEmpty(cancel))
    {
        Cancel(); 
    }  
    //etc
} 

Is there any workaround for this? Thanks. Note that I don't have this problem in IE8 or firefox.

+1  A: 

Have you seen this?

Cause
The .NET framework is throwing up an error because it detected something in the entered text which looks like an HTML statement. The text doesn't need to contain valid HTML, just anything with opening and closing angled brackets ("<...>").

The solution proposed there is to disable the request validation on the server-side:

<pages validateRequest="false" />

Be sure to read through the warnings and explanations as well.

Tomalak
I really wouldn't want to deactivate that (It's kind of an extreme workaround imo), because there are more fields that require user input. The real problem is that it works great without the jquery code (I edited my question with more info) and most browsers, but somehow the extra styling messes up IE 6.
Francisco
@Francisco: I would probably look at the data that goes over the wire (via a packet sniffer) to compare any differences between the browsers where it works and those where it doesn't. I'm not really into ASP.NET MVC, so I can't tell you what's wrong straight-away, sorry.
Tomalak
No problem, thanks anyway =)
Francisco