1.FromUri使用

将数据通过url方式传递。我们需要在webapi方法标明,这个参数只接受url中参数的值,

$("#Save").click(function () {

           $.ajax({
               url: 'http://localhost:21162/api/person/?str1=1&str2=3',
               type: 'Get',
               dataType: 'json',
               success: function (data, textStatus, xhr) {
                   console.log(data);
               },
               error: function (xhr, textStatus, errorThrown) {
                   console.log('Error in Operation');
               }
           });
       });
public IEnumerable<Person> GetAllPerson([FromUri] string str1, [FromUri] string str2)
{
    return new List<Person>() {
        new Person() {ID="1", Name="李鸿章ALL",Age=15},
        new Person() {ID="2", Name="杨玉红ALL",Age=15} };
}

 

WebAPI的属性和相关操作 FormBody和 FormUri等

 

 

 

相关文章:

  • 2021-10-17
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
  • 2021-06-23
  • 2021-12-22
  • 2021-07-18
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-09-26
相关资源
相似解决方案