asp.net mvc 4 - Web-Api 400 BadRequest when search parameter is blank -


i using web-api mvc4

i making searching functionality, in cases if filter data remove textbox value , press search button, need show whole listing in case showing 400 bad request. search parameter blank, know if search parameter blank throw 400 error web-api.

any 1 have proper solution please let me know.

data: "currpage=" + jscurrpage + "&pagesize=" + parseint(pagesize) + "&buildtypename=" + $("#buildtypename").val(), 

here in cases buildtype blank. when search made

//controller

public httpresponsemessage getbuildtypelist(int currpage, int pagesize, string buildtypename)         {          } 

net -> xhr url :

http://{parenturl}/api/buildtypewebapi/getbuildtypelist?currpage=1&pagesize=10&buildtypename= 

if allow currpage , pagesize empty, need accept nullable ints:

public httpresponsemessage getbuildtypelist(int? currpage, int? pagesize, string buildtypename) 

then, you'll update query return entire list if no filter values provided.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -