How to allow special chars in form for a specific page?

99 Views Asked by At

I saw a lot of similar questions here, but no answer worked for me. I have a site (MVC4) with a search function, the search function should accept any character, but only the search form, the rest of the site should work with MVC4 default settings.

I tried the web.config bellow with no success.

<location path="Views/Search">
  <system.web>
    <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" />
    <pages validateRequest="false" />
  </system.web>
</location>

Also my Controller uses the attributes HttpGet and ValidateInput(false)

...
[HttpGet, ValidateInput(false)]
public ActionResult Search(string text)
{
...

What am I missing?

Edit: I'm using Razor 2

1

There are 1 best solutions below

1
Sasha On

Try declaring page with disabling input characters validation for HTML injection:

<%@ Page Language="C#" ValidateRequest="false"%>