title: ValidateInput(False) not working when using window.location.href to call mvc and gives action dangerous request
body: <p>I'm using asp.net mvc 4 (vb) and I'm stuck at this last part to really finish my search functionality. The ValidateInput(False) parameter works on every single call, except when I'm using a call via javascript. 
  The error I get is the following: A potentially dangerous Request.Path value was detected from the client (&lt;).
  I get this when I'm trying to search on something html-like.</p>
  
  <p>I'll list the code I'm using:</p>
  
  <p>MVC view:</p>
  
  <pre><code>&lt;input type="text" id="searchtextMVC" name="query" onkeydown="EnterKeyDownForWhoIsWho(event);" data-url="@Url.Content("~/Controller/")"/&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>window.location.href = $('#searchtextMVC').attr('data-url') + 'Index/' + document.getElementById('searchtextMVC').value;
  </code></pre>
  
  <p>these two fix it so I get my correct url with parameter.</p>
  
  <p>My action starts like this:</p>
  
  <pre><code>&lt;ValidateInput(False)&gt; _
          Public Function Index() As ActionResult
               Code stuff, eventually using CStr(RouteData.Values("fullName"))
  </code></pre>
  
  <p>Now the problem is the ValidateInput works on every call EXCEPT for the one via javascript.
  I have also added requestValidationMode="2.0" to my web.config, but that didn't help. I need to give the parameter fullName for my function to work.</p>
  
  <p>I've spent too much time searching on the internet for no answers, so I hope we can figure this out together.</p>
  
  <p>EDIT: I forgot to mention I also tried requestPathInvalidCharacters="" in my web.config and this made it so that I always got an illegal character error.</p>
  
  <p>EDIT2:</p>
  
  <p>I tried url-encoding in the javascript, but it didn't help. Here's what I tried:</p>
  
  <pre><code>searchValue = $('#searchtextMVC').attr('data-url') + 'Index/' + encodeURIComponent(document.getElementById('searchtextMVC').value);
  </code></pre>