Thursday, 15 September 2011

c# - Search Issue in ASP.NET MVC 4 -


I'm new here and have a question about a search piece of code in MVC 4. I have this piece of code:

  Public Action Result Index (string searchTerm = null) {var model = entities. User Where (m => gt; search == faucet || m.seurenm.cttain (search)). Select (M = & gt; New userview module {name = M. name, SureName = m.SureName, Department = M. department, mail = M. mail}); }   

Index.cshtml

   & Lt; Input type = "submit" value = "search ..." /> & Lt; / Form & gt; @forcha (various items in the model) {& lt; Div & gt; & Lt; H4 & gt; @ Item number, @ item Suranam & lt; / H4 & gt; & Lt; Div & gt; @ Item.Department, @ item.Mail & lt; / Div & gt; & Lt; / Div & gt; }   

By the time I run it, it works until I want to find anything. The problem is in routing because if I manually type ": XXXX /? SearchTerm = Luk" everything is working fine. But when I do this on page URL, it looks like "": XXXX /? SearchTerm + = Luk "Does anyone know, why is + Icon ?? I think I have this issue.

You have a white space here: & lt; input type = "search" name = "searchTerm" />

This will encode "+" in your query string. Remove the white space from the "Name" attribute and you should be OK.

No comments:

Post a Comment