网络的API 400错误请求时,搜索参数是空白 [英] Web-Api 400 BadRequest when search parameter is blank
问题描述
我使用的网络API和mvc4
我正在搜索的功能,在某些情况下,像如果我过滤数据然后删除文本框的值,然后preSS搜索按钮,需要显示整体上市,但在我的情况下显示400错误的请求。作为搜索参数是空白的,我知道,如果搜索参数为空,然后它会抛出400错误与网络的API。
任何一个有妥善的解决办法,那么请让我知道。
数据:CurrPage =+ JsCurrPage +&放大器;每页=+ parseInt函数(PAGESIZE)+&放大器; BuildTypeName =+ $(#BuildTypeName)VAL(。 )
下面在某些情况下BuildType是空白的。当搜索做
//控制器
公开的Htt presponseMessage GetBuildTypeList(INT CurrPage,诠释每页,串BuildTypeName)
{ }
网络 - > XHR网址是:
<$p$p><$c$c>http://{parentURL}/api/BuildTypeWebApi/GetBuildTypeList?CurrPage=1&PageSize=10&BuildTypeName= 公开的Htt presponseMessage GetBuildTypeList(字符串BuildTypeName,诠释CurrPage = 1,中间体每页= 0)
在你的业务逻辑,你可以假设为0每页意味着所有记录。
I am using web-api with mvc4
I am making searching functionality, in some cases like if i filter data then remove that textbox value and then press search button, need to show whole listing but in my case showing 400 bad request. as search parameter is blank, i know if search parameter blank then it will throw 400 error with web-api.
any one have proper solution then please let me know.
data: "CurrPage=" + JsCurrPage + "&PageSize=" + parseInt(pagesize) + "&BuildTypeName=" + $("#BuildTypeName").val(),
Here in some cases BuildType is blank. when search made
//controller
public HttpResponseMessage GetBuildTypeList(int CurrPage, int PageSize, string BuildTypeName)
{
}
Net -> XHR URL is :
http://{parentURL}/api/BuildTypeWebApi/GetBuildTypeList?CurrPage=1&PageSize=10&BuildTypeName=
public HttpResponseMessage GetBuildTypeList(string BuildTypeName, int CurrPage = 1, int PageSize = 0)
In you business logic you can assume that a PageSize of 0 means all records.
这篇关于网络的API 400错误请求时,搜索参数是空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!