Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取.NET ApiController的默认参数_C#_Asp.net_Asp.net Web Api - Fatal编程技术网

C# 获取.NET ApiController的默认参数

C# 获取.NET ApiController的默认参数,c#,asp.net,asp.net-web-api,C#,Asp.net,Asp.net Web Api,我正在为项目构建API,在获取操作的默认参数方面遇到问题 这是样品 [HttpGet] //Without =null its not worked same way public IEnumerable<UserModel> GetFilter([FromUri]UserFilterListModel filter = null) { var res = repo.GetFilterList(User.AccountId, filter); return res.

我正在为项目构建API,在获取操作的默认参数方面遇到问题 这是样品

[HttpGet]
//Without =null its not worked same way 
public IEnumerable<UserModel> GetFilter([FromUri]UserFilterListModel filter = null)
{
    var res = repo.GetFilterList(User.AccountId, filter);
    return res.Rows;
}
第一条路线运行良好,但当我执行第二条路线时,服务返回

<Error><Message>The argument cannot be null</Message></Error>
参数不能为null
我尝试在没有参数的情况下实现Get,但在路由的多个操作中出现Get错误

如何使这两条路线都正常工作

PS:im创建了自己的AttributeOutfactory,也许是其中的邪恶根源?

我认为你的问题不在于路线。我认为如果第二个参数为null,
repo.GetFilterList
不起作用。但是我现在不能尝试这个。不,执行不会到达repo.GetFilterList,无论如何它有空处理程序
<Error><Message>The argument cannot be null</Message></Error>