Click here to Skip to main content
15,892,643 members
Everything / WebAPI

WebAPI

WebAPI

Great Reads

by kusnaditjung
Web specification and framework
by Fred Song (Melbourne)
Build a simple finance application with Angular 13 and .NET 6
by John Atten
When working with ASP.NET Web Api from a .NET client, one of the more confounding things can be handling the case where errors are returned from the Api. Specifically, unwrapping the various types of errors which may be returned from a specific API action method, and translating the error content in
by Vincent Maverick Durano
This article will talk about how to implement a custom wrapper for your ASP.NET Core and Web API applications for managing exceptions, providing meaningful and consistent responses to consumers.

Latest Articles

by Zijian
Use the codes generated by OpenApiClientGen in real world applications
by Zijian
Construct Angular Reactive Forms of client data models through generated Angular TypeScript codes
by Zijian
Construct Angular Reactive Forms of client data models through generated codes
by Zijian
A series of articles comparing programmer experiences of Angular, Aurelia, React, Vue, Xamarin and MAUI

All Articles

Sort by Updated

WebAPI 

5 Oct 2016 by #realJSOP
List locations = new List();DataTableReader reader = dt.CreateDataReader();if (reader != null && reader.HasRows){ while (reader.Read()) { locations.Add(new Locations() { // call the appropriate reader.GetXXXXX mthod that is...
27 Feb 2018 by #realJSOP
I wouldn't worry about maintaining an archive of older files unless that's a specific requirement. If it is, you can establish a max number of old files to maintain to keep disk usage on the file system server to a dull roar. Files can quickly overwhelm available disk space on a busy site. You...
15 Oct 2019 by #realJSOP
That's highly inefficient and requires a sh*t-ton of needless code. Just save the whole entity and be done with it. If your entities and DAL are properly designed, this shouldn't be an issue.
4 Apr 2020 by #realJSOP
0) Don't post stuff on imgur that can easily be posted here. 1) You can't create json without data in your objects. 2) Your model isn't complete. There is no AtlasTransaction object defined in your example code 3) Why are you serializing it...
31 May 2020 by #realJSOP
Caveat - Your question sucks because you didn't tell us what your actual problem is. Because of that, my proposed solution is can be rightly called a "wild-assed-guess". Proceed as you see fit. I suspect that you're finding that, while you can...
29 Aug 2017 by .net developer123456789
Hello All, My Code here. string uriString = "http://www.Testcom"; WebClient myWebClient = new WebClient(); string postData = "data"; myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded"); Console.WriteLine(myWebClient.Headers.ToString()); byte[] byteArray =...
10 Dec 2021 by .NET- India
Hi, Getting following error in HttpPatch "The JSON value could not be converted to Microsoft.AspNetCore.JsonPatch.JsonPatchDocument" I have created an application and using following code but debug is not being focused on [HttpPatch] ...
20 Apr 2021 by .NET- India
Hi, I am able to send email in asp.net core web api with attachments but attachments exists locally in a folder of api application. But i want to send attachment dynamically i.e. ...
17 Aug 2021 by .NET- India
Hi, I am writing following code in .NET Core Web API. And project is divided in "API", "Service", "Repository". I have following request body and it is sending a mail with an attachment with a link given in "Attachment". { "To":...
14 Sep 2021 by .NET- India
Hi, Special Characters of French being converted into black diamond with question mark into Email on Server but at localhost everything is ok Example:- Conversion of special characters Real Word:- Converted into Mail d’avoir ...
20 Sep 2021 by .NET- India
Hi, Sending message using MailMessage, working fine in localhost but after uploading on Server giving error as given below. The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0...
12 May 2016 by 1Future
HI All,I have a model like this:public class Employees{ public int Id {get;set;} public string Name {get;set;} public DateTime StartTime {get;set;} public DateTime FinishTime {get;set;}}Then I have a webapi controller returning the details against a...
12 Mar 2016 by 23741
Do you have Fiddler installed? If so - you may see a better error explanation in the response.
2 Jul 2017 by 9000605667
I am writing one .net API for Android, Ipad apps and Web application So i am little bit confusion which is suitable for above kinds of app. So Please give me guidance which can i pick to start (i.e) Web API (or) REST. Thanks, What I have tried: So Please give me guidance which can i pick to...
29 Jun 2018 by 9000605667
after hosting the web apI applcation in godaddy. After browing in the URL i am facing the error What I have tried: Server Error in '/' Application. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this...
22 Feb 2015 by _Maxxx_
I think, to me, the Person controller needs to handle this.A Person needs to know about a Phone - but a Phone needs no knowledge of a Person.So your phone controller shouldn't need to know about Person at all.
21 Mar 2020 by _ProgProg_
Hello, I want to generate a specific report and download it through a web api. I am using dotnet core 3.1 Can i do it with RDLC or any other tool? What I have tried: i searched for that bust most is through angluar FE and i want it through...
18 Sep 2015 by Aakash Bashyal
i have a request in xml or json. How can i check whether the request contain a missing body or invalid body item. content-type:application/json;Method:Post;{"UserName":"tom12","Password":"XXXXXXXXX","FirstName":"tom","LastName":"jack", "MiddleName":"dick"}their may be MiddleName...
29 Sep 2016 by AbassiOmar
hello I have a web api 2 which called for a stored procedure and I almost called this 3000 web api so I have 3000 execution of a stored procedure and certain moment I had a bug conextion timeoutmy comandTimeout is 3 minute what the solution at the architecture or the SQL Server level to...
6 Mar 2022 by Abdo AJ
Hi There ! you already done the half of it you can Store data in JWT such as device unique identifier or any other data that helps you identify the user and get it at every request for the clint side there a payload section at jwt allow you to...
14 Aug 2018 by abdul shakib
Web Service It is based on SOAP and return data in XML form. It support only HTTP protocol. It is not open source but can be consumed by any client that understands xml. It can be hosted only on IIS. WCF It is also based on SOAP and return data in XML form. It is the evolution of the web...
29 Apr 2015 by Abdul Shakoor p
I have Models "Category" & "SubCategory". CategoryID is foreign key in SubCategory Table. I need to fetch all the Category and related SubCategories and bind in an Accordion list.This is my code :
20 Jan 2016 by Abhijit Parab
Hi, I am trying Jqgrid using web api in mvc4. i have proper libraries for jquery and jqgrid. but still on loading of view page it raise error as "Object doesn't support property or method 'jqGrid'" Following is the code for that. It will be help if i get solution for this.@{ ...
18 May 2017 by Abhijit S Kulkarni
Token Based Authentication for Web API
15 Aug 2012 by Abhinav Moudgil
I have a Html page on which I want to make a call to an external API and display data being fetched from there.For Example: I have a page test.html and there is and Api : http://testwebsite.com/api/namedisplay.NOw this service returns the name and I want to display them on my Html page...
26 Jul 2014 by Abhinav S
Check out click once deployment first.
17 Feb 2015 by Abhinav S
Using HttpClient -var client = new HttpClient();var dto = new Dto {prop1 = "value"};var reponse = client.PostAsJsonAsync("api/methodput", dto).Result;
11 Nov 2015 by Abhinav S
Tons of information available on the internet. More links -Build your firstWeb API with MVC[^]Understand about DELETE Verb in Web API RESTful Services using Data from Both Request Body As Well As URI[^]Integrating Web API with ASP.Net[^]
12 Nov 2015 by Abhinav S
You need to send your token with each request in the Authorization Header.Try this out[^].
14 Feb 2016 by Abhinav S
There is no need for System.web in ASP.Net 5.You need to use .Net core instead.Alternately, switch back to version 4.5.2.References - ScottGu's Blog - Introducing ASP.NET 5[^].Top 10 Changes in ASP.NET 5 and MVC 6 | Stephen Walther[^]
2 Feb 2013 by Abhishek Pant
Google I/O 2012 - Building Android Applications that Use Web APIs [^]Accessing Web APIs[^]
21 Mar 2017 by abhishek_singh
Hi,I have created a web api service with window authentication for Intranet users in ASP.NET Core, Authentication on service is working properly except that it accept all domain user which have valid credentials for requested machine, I just want that it validate for single domain users only,...
26 May 2014 by abkcareer
I'm working on a RESTful mobile application using ASP.Net Web APIs. I am inclined to use Basic authentication. I have followed some articles which gave me good start. I understood that "username:password" will be encoded and added to "Authorization: Basic " and sent it as header on subsequent...
23 Mar 2015 by Accusoft, Ned Averill-Snell
Watermarking in an HTML5 viewer allows sharing sensitive document content while curbing the potential for unauthorized use. This paper shows how the application of JSON properties in the body of an HTTP viewing session request can be used to apply watermarking to a document.
31 Jan 2018 by Adityakumar2318
I am using webapplicaton and i am able to store the log error(default which is provided by log4net)in the table. But i want to add some more column and want to store the error in that field to. CREATE TABLE [dbo].[Log] ( [Id] [int] IDENTITY (1, 1) NOT NULL, [Date] [datetime] NOT NULL, ...
31 Jan 2018 by Adityakumar2318
Please close this question. I just figure out the issue. Below is the link. Thanks. c# - Log4Net, how to add a custom field to my logging - Stack Overflow[^]
7 Feb 2018 by Adityakumar2318
This below code is working fine, i just wanted to do it using webclient without async. Or can we remove anyways asnc from below method and make it like regular method. // Calling method from program.cs using console application static void Main(string[] args) { ...
29 Sep 2017 by adityasahver
In this tip, we will learn how to enable the Certificates in the Azure Web Sites
17 Dec 2019 by AFell2
Is the CPersonMasterBase class you are using as the "person" property an abstract class? If not, does it also have a parameterless constructor?
14 Dec 2014 by Afzaal Ahmad Zeeshan
To upload the files without a POST request (page refresh) you would need a client-side framework. JavaScript is one of them. You should be using jQuery, to make things easier.You can create a new ajax request (Ajax request is required, there is no other way for you to send the data to the...
4 Jun 2015 by Afzaal Ahmad Zeeshan
The absolute and obvious solution to this problem has already been found on Google, CodeProject and other programming communities. You can surely get it from there.Short answer: The assembly that you want to use is not found, the framework is not installed or found. To use it, install the...
12 Nov 2015 by Afzaal Ahmad Zeeshan
Web API is actually accessible through HTTP protocol, it doesn't say whether it is accessed by a web browser or an application. Web API would always respond to requests coming on HTTP, web browsers do send the requests through HTTP, that is why Web API is always accessible from a web browser...
30 May 2016 by Afzaal Ahmad Zeeshan
In this article of mine, ASP.NET 5 Web API RESTful CRUDs and Windows 10 native application[^], I have talked about the HTTP verbs, POST and PUT. The problem is not with using which one, the problem is how to use the HTTP verbs in a way that they are meant to be used. Using bad practices, I...
31 May 2016 by Afzaal Ahmad Zeeshan
You just need to purchase a subscription from any hosting provider. There are multiple solution providers that provide competing packages for the companies and individuals. You can select from one of them. Since this is ASP.NET, I'd like to say you should go and visit here, ASP.NET Hosting | The...
21 Sep 2016 by Afzaal Ahmad Zeeshan
Quote:I was searching difference between WebApi and WEF REST and in almost every artical I found that WebApi is lightweighted than WCF REST but none of them told "why".I will tell you the "why" part of their posts and the increased interest in this question is motivating me to write an article...
4 Dec 2016 by Afzaal Ahmad Zeeshan
A few things to note here, first of all use the following type for script, But this is not necessary at all now, browsers are smart enough. You can always omit this and it will work. Secondly, jQuery code needs to come inside a handler otherwise $ won't...
5 Jan 2017 by Afzaal Ahmad Zeeshan
What you were writing was more than enough, before I say anything else, there is also no need to make it readonly, as you are just using it to access data, not modify its values (even in the second code). Now like you said, using block is efficient as it clears out resources as soon as the...
25 Jan 2017 by Afzaal Ahmad Zeeshan
First rule of POST requests. Do not F*ck the URLs! URLs and query strings are only used to GET the data. When you are issuing an HTTP GET request, use Query Strings or URL routings etc. to get the data, add the filtering to the content. But when you are going to post the data, always use the...
30 Mar 2017 by Afzaal Ahmad Zeeshan
You may use this, RNGCryptoServiceProvider Class (System.Security.Cryptography)[^] and it provides a secure random — not a seeded random number. In most secure cases this is the random number generator that should be used instead of the plain old Random class of the .NET framework. You can read...
7 Jun 2017 by Afzaal Ahmad Zeeshan
Just the way you will consume it in any other application; console, WPF etc. All that you would need is an HttpClient object and the rest is all documented. :-) Like you have mentioned, you wanted to open it up at "localhost:8080", are you sure that is the location where your API is currently...
16 Feb 2019 by Afzaal Ahmad Zeeshan
As already mentioned in Solution 1, by MadMyche, you cannot simply convert your applications to an API, where API itself is a separate way or method of development of applications. An API has so many requirements, such as being stateless, headless, and cross-platform, and cross-device. APIs work...
1 May 2020 by Afzaal Ahmad Zeeshan
Quote: Also I doubt they can distribute it also. Which they will, which is why online pirated software copies of Windows, Office, and other premium software like Adobe are available. You do your best to prevent the usage, by locking the software...
16 Feb 2019 by ahmed_sa
problem How to convert that code please from mvc project to web API I work on mvc project in asp.net core 2.1 I create Employee Controller and inside it I make two function action result for create new employee and save it as following : I decided to convert above functions to web API so...
22 Mar 2019 by ahmed_sa
problem get error when make service getallemployee Conversion of type 'Promise' to type 'Employee[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352) Conversion of type 'Promise'...
20 Feb 2019 by ahmed_sa
problem when pass id value of put(update) from postman it passed as 0 although it have value on link ? i select key from post man as contenttype application/json and this is my url https://localhost:44326/api/Employee/put?id=5 and when put breakpoint in function put and run app it hit...
6 Aug 2019 by ahmed_sa
Problem which is best for make authentication security using ado.net or using identity user JWT Security ? I work on big team working on doing ERP web system using asp.net core 2.1 . we using Ado.net classes and function and we dont use Entity framework Core 2 we need to to make security to...
21 Jan 2020 by ahmed_sa
Problem what type of return in case of user exist on database asp.net core web api ? I make function create user on database by web API asp.net core and it working without any problem . I notice more users repeated so that i need to prevent user repeating records on database . I make...
7 Dec 2020 by ahmed_sa
I work on asp.net core 2.2 Project with angular 7 . I face issue when download file It created with Name [object FormData].xlsx but Name must be DeliveryGeneration_Output.xlsx . Path returned and Created ...
31 Aug 2021 by ahmed_sa
I work on asp.net core 2.2 web API using C# language I need to rewrite function below with best syntax and with best practice web API below get Excel file from upload and return Excel file it working without any issue but I need to rewrite it...
7 Sep 2021 by ahmed_sa
I working on web api asp.net core 3.1 I need to return export path direct without copying to memory so How to do that Please ? How to return export path without copy to memory as below return File(memory2, "text/plain",...
13 Sep 2021 by ahmed_sa
I work on c# 7 I face issue I can't get data from file Request.form.file[0]� directly� it must copying to server to get data from it� so can i get data from variable DisplayFileName� instead of get data from input path after copying to server ...
1 Apr 2022 by ahmed_sa
I work on asp.net core 2.2 i face issue I can't modify web api to display message "Not Matched Compare" when compare excel function return false (areIdentical == false) . web api below return physical file as zip file in case of compare excel...
13 Apr 2022 by ahmed_sa
i work on web page web api and angular 11 this page take input file excel and get result on excel file as output i get error i don't know what is the reason of error and how to solve it error as below Access to XMLHttpRequest at...
17 Oct 2022 by ahmed_sa
I work on iis i need to publish web application angular 11 and asp.net core 3.1 on iis (web api ) are there are any web site or video explain that from scratch please my app contain to web api csharp as backend with angular 11 are there are any...
22 Oct 2022 by ahmed_sa
I work on visual studio 2019 when create new project with .NET core web application it display to me as .NET core 2.1 i need to create new project on visual studio 2019 with .NET core 5.0 so what i do to display .net core 5.0 when create new web...
25 Nov 2022 by ahmed_sa
I work on .csharp net core 5 i need to create blazer app with good architecture with clean code are any one know GitHub link source code for that or any sample on internet site i can follow it . What I have tried: sample for blazor good...
1 Dec 2022 by ahmed_sa
I work on web application asp.net mvc core .net 5 i can't modify action login to accept 3 login attempt failed only . if he try with wrong password or wrong email account after that then block it . so how to using session to allow user enter...
4 Dec 2022 by ahmed_sa
I working on .net 5 mvc i have table name cinimas have 5 rows . my issue I can't display these 5 rows on custom view model . I try but no rows display what I try 1- model creation public class Cinema:IEntityBase { [Key] ...
26 Dec 2022 by ahmed_sa
I work on a web application with ASP.NET Core 6 and Angular 13. This application displays a list of items successfully without any issue. My issue happens when there's pagination for the items displayed. I get an error in the console: ERROR...
24 Oct 2023 by ahmed_sa
I work on ASP.NET MVC Project. I face issue action ApprovalIndex Not redirect to action PendingManagersRequests although no error happens. I debug and trace breakpoint until I reach action PendingManagersRequests and trace until I reach to view...
14 Apr 2017 by AhmedYehiaK
Hi everyone, I have a web API which communicate with multiple external services (SOAP, REST, etc) all requests to external services are in parallel (60~70 request created at moment) i need to now what is the best practice to log all requests and responses. I need to now the best method in...
10 Dec 2018 by Aitzaz Ahsan
This is my statrup Class public partial class Startup { public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); ConfigureOAuth(app); WebApiConfig.Register(config); ...
6 Feb 2023 by Ajas Aju
I have the same issue not resolved yet. My API Code: HttpPut("updateThemeDetail/{whiteLabelId}")] public async Task UpdateThemeDetail([FromForm]TenantThemeSetUpInput item, string whiteLabelId) ...
8 Nov 2016 by Ajay-Systematix
Hello,Re: [{"NationalCode":"12458","LicenceCode":"4582aS","Phone":"45236987"}]You can direct access it using:View:success: function (response) { var groupVal = response.NationalCode; } Let me explain you:Controller:public JsonResult...
24 Nov 2022 by ajay.raju531
Hi, How to send form-data using HttpWebRequest post method. Please check my code and advise me how to set request.ContentLength and pass formData to request. for "x-www-form-urlencoded" content-type, I have used like. Stream requestStream =...
20 Oct 2015 by Ajay_Patel
Hey there,I need to pass some custom information with my JSON Web Token in asp.net web api.Right now it only returns access_token,expires_in and token_type properties but I need to pass some additional information along with those properties like user_name,user_roles etc. I now the json...
4 Jul 2023 by Akaash Kumar
As in Postman we have certificate and key file, how do I validate the KEY file using c# or MVC. I have tried adding the below code but seems like for the KEY file we've some other code to write. Please suggest some help. What I have tried: ...
12 Jan 2016 by akash_pjr
I want to display connections in my website in the form of pie chart. How to access the connections API via my web application(application name "LLogin")? I have access to only few information(name,no of connections,location,summary). I want connection's designation,location etc.
16 Jun 2014 by Akhil Mittal
Add the below code in your web.config of your API under tag
1 Mar 2016 by Akhil Mittal
My article will explain how we can make our Web API service architecture loosely coupled and more flexible.
1 Mar 2016 by Akhil Mittal
In this article I’ll explain how to write your own custom routes using Attribute Routing.
1 Mar 2016 by Akhil Mittal
This article will explain how to make WebAPI secure using Basic Authentication and Token based authorization.
7 Mar 2016 by Akhil Mittal
In this article we’ll learn on how to write unit tests for WebAPI controllers i.e. REST’s actual endpoints.
1 Apr 2016 by Akhil Mittal
This is the last article of the RESTful series in which I’ll explain how you can leverage OData capabilities in ASP.NET WebAPI. I’ll explain what OData is and we’ll create OData enabled RESTful services.
14 Apr 2016 by Akhil Mittal
In this article I’ll explain how we can host aWebAPI in another process independent of IIS.
5 Jul 2016 by Akhil Mittal
This article will focus on practical aspects of formatters and content negotiation in ASP.NET Web API
30 Jul 2015 by Alan Balkany
My controller action with two parameters is never called. Can anyone see what I'm doing wrong?URL: /api/JobTitle/1/55 (The arguments are 1 and 55.)ROUTE: config.Routes.MapHttpRoute( name: "With2Ids", routeTemplate: ...
16 Jul 2013 by Aleksandar.S
Hello everyone,I'm trying to make an IP camera proxy/relay. To clear what that is, a camera can hold up only up to 15 connections. Since this should be used with a larger number of users, my idea is to make a REST web service with Web API and serve an MJPEG stream to every user. The source...
29 Oct 2012 by Alex Berd
Hi GuysIn the last month I studied the new Microsoft technique of MVC 4 the WEB API. For the application development I installed the Microsoft plug-in for VS2010 that provide MVC4 functionality in it.I read a lot of articles about this technique and build the application that is work...
5 Jun 2017 by Alexander Kozlovskiy
Used for binding custom types (including files) when sending and receiving multipart encoded form data
4 Dec 2015 by Alexander Siniouguine
Discover Bower and Gulp with Visual Studio 2015
31 Oct 2016 by Ali Majed HA
HelloI have a tree :Id Title ParentId1 A 02 B 13 C 24 D 3How can I remove all children on removing "A" using Entity framework and jqxTree?What I have tried:TableTree _TT = _Entity.TableTree.where(c => c.Id ==...
8 Nov 2016 by Ali Majed HA
HelloI have function in my Controller and I have fetch data from data base in string format. the result is : [{"NationalCode":"12458","LicenceCode":"4582aS","Phone":"45236987"}]that i pass it to my JavaScript file. How can access to the fields of this string.I mean access to...
28 Nov 2016 by Ali Majed HA
helloI am coding an online-shopping system Cart with JavaScript. my problem is to update Total Price, when the product quantity changes, I don Not know how to do that. related codes are:HTML: ...
8 Dec 2016 by Ali Majed HA
HelloI have an element in my .html file. When user select his/her image, I get the selected image using JavaScript and send it to controller as JSON:var _Data = { Image = $("#ImageFileUpload").val();and in my controller, I save it in my Data Base:byte[] binData;byte[] byteArrey...
10 Oct 2017 by ali_1
I created a WEB API using asp.net with basic authentication. Here is my get Method link : localhost:XXX/api/Products/X1 But the client need the request and response in XML format with Products id and authentications credential included in it . Example :
15 Oct 2017 by ali_1
Hi All , Can I use soap requests Restful Web API ? I have a basic authentication and need to send ProductID in the request . the request should be like below:
4 Nov 2018 by ali_1
Hi All, I am looking for a sample microservice application with at least two services. I am confused about how the API gateway is managing the requests from services and how it is transferring the data to UI? What I have tried: I have created three services and a web application, but don't...