You must Sign In to post a response.
  • Category: ASP.NET

    How to create Web API in .Net with Get Method using multiple parameter ?

    How to create Web API in .Net with Get Method using multiple parameter ?
  • #766810

    As per your post I came to know you want basic knowledge in Web API, I suggest you to go through the below links, those might be helpful to you.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #766859
    Study the Webclient class which has namespace in System.Net.So you will get deep idea what is WebAPI.

  • #766951
    I am requesting a .php page and passing function as an argument which in php page

    string URI = @"http://XXX.XXX.XXX.XX/XXXXXX/index.php?fn=addSession";
    WebClient wc = new WebClient();
    string URI = @"";
    WebClient wc = new WebClient();
    NameValueCollection inputs = new NameValueCollection();
    inputs.Add("fn", "addSession");
    inputs.Add("id", sessionid);
    inputs.Add("step", stepid.ToString());
    inputs.Add("option", type);
    inputs.Add("date", datetimenow.ToString());
    inputs.Add("view", "0");
    inputs.Add("datefrom", fromdate.ToString());
    inputs.Add("dateto", todate);
    inputs.Add("numfrom", numfrom.ToString());
    inputs.Add("numto", numto.ToString());
    inputs.Add("word", EncryptionDecryption.Encrypt(keywords.ToString(), true));
    inputs.Add("phrase", EncryptionDecryption.Encrypt(phrases.ToString(), true));
    inputs.Add("other", otherfiledetails);

    byte[] retvalue = wc.UploadValues(URI, inputs);
    string value = ASCIIEncoding.ASCII.GetString(retvalue);

    it will invoke and return the value in string. So please go through the below url


  • #766952
    I hope you know the concept of WEP API in .net. So I am not going to explain more about it. According me you can do this in two ways. You can add parameters in the WEP API method. So you can send the parameters as query string from the client call. The query string values will be the parameters
    For example if you are sending http:\\localhost\AppName\Webmethod?Name=test&Age=26

    In the above method Name and Age will be you parameters of your web API method.

    Then second ways is create class having multiple properties and do the post method and get the result.

    using (var Myclient = new HttpClient())
    Myclient.BaseAddress = new Uri("http://localhost/AppName/");
    Myclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    HttpResponseMessage Myresponse = await client.GetAsync("webapi/Items");
    if (Myresponse.IsSuccessStatusCode)
    List MyItem = await response.Content.ReadAsAsync>List>();

    The above is the sample code for access the web api method with derived type

    By Nathan
    Direction is important than speed

Sign In to post your comments