Optional query string parameters in ASP.NET Web API

后端 未结 5 1158
粉色の甜心
粉色の甜心 2020-12-07 08:57

I need to implement the following WebAPI method:

/api/books?author=XXX&title=XXX&isbn=XXX&somethingelse=XXX&date=XXX

All of

5条回答
  •  自闭症患者
    2020-12-07 09:25

    This issue has been fixed in the regular release of MVC4. Now you can do:

    public string GetFindBooks(string author="", string title="", string isbn="", string  somethingelse="", DateTime? date= null) 
    {
        // ...
    }
    

    and everything will work out of the box.

提交回复
热议问题