Questions tagged [asp.net-web-api2]
ASP.NET Web API 2 is a framework for building HTTP services for clients like browsers and mobile devices. It is based on the Microsoft .NET Framework and an ideal choice for building RESTful services.
7,669
questions
0
votes
1
answer
23
views
Trying to do a slightly larger than average AXIOS.post to a .NET Web API
I'm trying to do an AXIOS.post in a Vue.JS application. It seems that when I get over about 1500 characters the process fails. What I mean by fails it does not even go to the Web API. It goes ...
0
votes
2
answers
39
views
First query with related data, result with duplicate data
I am trying to perform a query where I must extract the information from the database as follows
Find the inventory number 1 that contains assets.
But I am getting a duplicate result in my assets ...
0
votes
1
answer
25
views
Cannot insert the value NULL into column 'created_date', table 'WebApp.dbo.Inventories';
I created a model BaseModel to inherit these 2 properties date_created and date_modified to all models in my database to keep a record when a record is created and when a record is modified.
I added ...
0
votes
0
answers
39
views
Connect Oracle DB with Entity Framework with Code First in VS2022
I need to connect with oracle database using entity framework in my MVC WebAPI project. I am using VS2022 with .Net Framework 4.8. I prefer working with code first approach and need to auto create the ...
1
vote
1
answer
48
views
Accepting body with generic type
I'm creating a web API that accepts a custom object. This works when someone does a POST request in JSON format. But now I have someone asking if they can post in XML, from my understanding this ...
-1
votes
0
answers
48
views
can a C# Class library be modified to become a Web API
I have a multi tier application.
Front end is an MVC project
Business and DAL are Class library projects.
BLL and DAL implement interfaces.
I do use dependency injection.
I was wondering if I could ...
0
votes
1
answer
93
views
How to use MassTransit with RabbitMQ for .net framework 4.6.1?
I want to use MassTransit with RabbitMQ for .net framework 4.6.1 project. I've followed this official doc to setup in WebAPI2 project using OWIN, but it is showing errors while building. It seems ...
0
votes
0
answers
67
views
Serilog.Sink.Elasticsearch, Could not create SSL/TLS secure channel
I am using Serilog and Serilog.Sink.Elasticsearch in an ASP web API project,
there is an issue with the connection to the ELK service that has been configured on an azure Kubernetes cluster, I get the ...
1
vote
2
answers
107
views
Returning different types from the same method
I have two objects that are similar but not quite the same:
public class ObjectA
{
public string PropertyA { get; set; }
}
public class ObjectB
{
public string PropertyA { get; set; }
...
0
votes
1
answer
20
views
Database Errors codes returning from api layer to a ui layer sep project
I keep coming back to this but what should I be returning from my database service call in my WeightLifting Service I have this code.
public async void CopySessionsPlayersToWeightLiftingBySessionId(...
0
votes
0
answers
19
views
How to syncronize data (application settings) between app pool
I have a static class, containing vaious settings fon .NET web api 2 (mostly parameters, links, flags etc.). Those parameters are filled from XML - file on startup.
The task is to make them changeable ...
0
votes
0
answers
16
views
Most efficient way to load a library at run-time (in ASP.NET MVC web API)
I originally had a library (workflow engine) and many of its dependency files all copied in the bin of my Web API and I had a direct reference to it. Needless to say, the bin folder looked a mess but ...
0
votes
0
answers
14
views
asp.net webapi not getting retrofit data when using post
I posting to a c# webapi from an Android app using retrofit2 and having trouble receiving the data.
Here is my test. I have populated the ScenarioRun object and it has an id of -1 indicating it is a ...
-1
votes
1
answer
124
views
ASP.NET Web API not logging exception in application insights when deployed in Azure
I have enabled application insights logging in my ASP.NET Web API project which is done from a class implementing IExceptionLogger. In debug mode it's logging exceptions to application insights using ...
0
votes
0
answers
51
views
Update multiple records via OData v3 endpoint, .NET and Entity Framework
The goal is to allow the user, who has navigated (via a data table control with per-field filter functions) to a set of records using GET requests to an IQueryable odata endpoint by refining their $...
0
votes
0
answers
10
views
Save information from webrequest in a WebApi to use furthermore
So i have a WebAPI which contain a number of endpoints for webrequestes that are sequential so to speak (you can only access the next webrequest when you already reach the one before it).
The problem ...
0
votes
1
answer
87
views
Getting 401 from custom Api when using Microsoft.Identity.platform to protect api
I am following the tutorial from Microsfot.document for how to protect api using Azure AD (Microsoft Identity).
The steps I took are following: Sorry I tried to put information that might be helpful ...
1
vote
1
answer
2k
views
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details
I'm Learning Webapi so I'm trying to build a simple Api connected to SQL server and I got this error when I add new Movie data
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while ...
0
votes
0
answers
12
views
How to invalidate MVC Controller cache from API Controller?
Home controller:
[OutputCache(CacheProfile = "UserCache")]
public ActionResult Home(string type)
Web.config:
<outputCacheProfiles>
<add name="UserCache" duration=&...
0
votes
0
answers
60
views
Is it possible to return text data and Bitmap image in Web API response?
I wanted to return text data along with image from web API. Response object looks like:
public class ApiResponse
{
public int Size { get; set; }
public string FontName { get; set; }
public ...
0
votes
0
answers
9
views
Display all APIs and parameters in Web API 2.0
Is there a way to display all of the APIs which is something like this.
I fear that as I code more, I will forget the parameters and the service name and I would need to open my source code to share ...
0
votes
0
answers
43
views
asp.net web api project deploy issue on godaddy shared hosting authorization and delegation settings
I have created a simple Web API project using Visual Studio. I tried to publish on godaddy windows shared hosting. Web publishing failed with the following error. Are there any additional server side ...
0
votes
0
answers
32
views
Asp.net Web API Microsoft Owin Refresh Token Not Working on Server
I have implemented refresh token using this link click here, and it is working fine on local machine but after deploying on Azure app service it is responding randomly, some times responding after 3 ...
-2
votes
1
answer
176
views
How to enable CORS on C# server?
I am developing a web app that has a cloud server (nodeJS) and a local server (C#) to interface the serial port of the PC. The web page whose origin is the cloud server makes requests to the local ...
0
votes
0
answers
30
views
C# web api Request if sometimes coming back null
so I have inherited this app, it is angular / .Net,
out api Controllers all inherit from a base controller
[AllowAnonymous]
public class BaseController : ApiController
{
protected static ...
1
vote
1
answer
137
views
Payment Gateway Integration between Android app and Web Api
This is my first time integrating a payment gateway. I am trying to integrate FlutterWave Payment gateway in my application. Its an Android app native with .net Web Api/Rest as backend. We deduct ...
0
votes
1
answer
35
views
dotnet WebApi + Client - ClientApp SPA is not protected by .AddAuthentication or .AddOAuth
I have a standard dotnet WebApi + Client application with the ClientApp folder containing a create-react-app SPA
In my Startup - I have .AddAuthentication
.AddAuthentication(options =>
{
...
1
vote
1
answer
29
views
C# Owin Auth - Common Token for the Webite and API
I have implemented the Owin Auth token approach in Web API(C#).
The question is, Can I use a common token for both Mobile App and the Website ?
If I create a token from the website and with this token ...
0
votes
0
answers
60
views
CORS - using Vary: Origin response header
Is there some way that I can configure ASP.NET Web API 2 application to use "Vary: Origin" instead of "Vary: Accept-Encoding" in the API's response header?
0
votes
0
answers
14
views
Getting Route Name in WebAPI (NOT MVC)
I have a controller that is using WebAPI, NOT MVC. It is a REST service.
If I have a method defined like this, is there any way I can get the Name property from the route that was used to reach my ...
1
vote
2
answers
233
views
Update multiple records using web api
Today in interview I got asked this kind of question.
Let's say you want to update multiple records same time using web api then how you can do that.
As it is around 1000s of records for updating..
So ...
0
votes
1
answer
89
views
How to have only one thread for fire and forget task in asp.net webapi?
I have a need in my asp.net webapi (framework .Net 4.7.2) to call Redis (using StackExchange.Redis) in order to delete a key in a fire and forget way and I am making some stress test.
As I am ...
0
votes
1
answer
173
views
Why are my POST requests blocked by CORS when deployed but it works locally
I have an Angular 9 frontend and a VB.NET Web API 2 backend.
When running both locally it works fine, however when they are deployed all the POST requests are getting blocked by CORS.
(GET works fine, ...
0
votes
0
answers
16
views
How do I implement a WebAPI POST method to allow a complex SQL statement
Hi there I have requirement to allow consumers of my ASP.Net WebAPI to extract data from an Oracle database using a user defined SQL statement. Obviously going with a GET request will not work in ...
0
votes
0
answers
14
views
Is it possible to use the date string vale from EFW and while on angular its model as a Date?
I have a EFW web API where initiationDate have a string value. However on the front end I am using p-calender to pick a date. In the model initiationDate is set ad date
initiationDate?:Date;
Now ...
0
votes
0
answers
44
views
Is it possible to convert a .net framework webapi2 project to a sdk project style?
Unfortunately I am working a webapi2 .net 461 project and I cannot move to .net core etc...
Can I convert it to sdk style project?
Is this supported? Doing some googling it looks like only ...
0
votes
0
answers
50
views
dynamic value is null because of Jobject filled with base64 encoded files
I have a VB.net application that need to call a C# web api with some parameters, including a lot of base64 encoded files.
I found out that the best way to pass this data to the application is to ...
0
votes
1
answer
20
views
parsing the result of web api
I am new in web api. I have called a external web api
var url = "http://service.mydomain.com/api/GetItems";
var parameters = new Dictionary<string, string>();
parameters["id&...
0
votes
0
answers
37
views
Max thread by connection in an ASP.NET ApiController
In an ASP.NET Web Api project with the SessionState disabled, if I create the following:
public class MyController : ApiController
{
[Route("doTheThing")]
public async Task ...
1
vote
0
answers
73
views
C# Web Api 2 Authentication.GetExternalLoginInfoAsync() return null
I'm trying Facebook Login for Web Api project. When try to call "api/Account/RegisterExternal", it is getting InternalServerError due to NULL return in info at var info = await ...
0
votes
2
answers
131
views
How to get method name from HttpRequestMessage?
I have handler like below and I want to get method name from Controller. Using var methodName = request.Method; just return only type of method like 'GET' or 'POST'. How can I get method name, ex. ...
0
votes
1
answer
39
views
How to get request and response from Web Api and save it to the database
I have a method in the Controller class below:
[HttpGet]
[ResponseType(typeof(RsContractCustomer))]
[Route("api/Contract/GetCustomerData/{cardModificationId}")]
public async ...
0
votes
0
answers
46
views
DataTable Datetime column deserialization from web API
I have a Web API which returns a datatable
public async Task<IHttpActionResult> SelectExtension(DateTime start, DateTime end, string institution)
{
var identity = (ClaimsIdentity)User....
0
votes
0
answers
32
views
Hangfire causing app to restart job every few mins
Ok So I am using hangfire for a background job but it appears to be enquing it self every few mins on a fire and forget call.
Also how do i properly report back progress of the call as you see am just ...
0
votes
4
answers
98
views
adding multiple values in object list in web api c#
I am new to web api and C#. I am creating a function where I am calling values from table which has 33 rows. the query is this:
Select * from T_SVRS_Reg_Trans
I have created a model where I have put ...
0
votes
0
answers
22
views
How to handle Web Api 2 exception when parameters are wrong type
I have a Web Api 2 application. One method accepts only integer parameters. If I on purpose pass a string instead, this error is returned:
{
"Message": "La solicitud no es válida.&...
0
votes
0
answers
12
views
Route not found and ExecuteBindingAsync of custom HttpParameterBinding is not being called
I need to pass a date to a Web Api action method. To accompish this, I have created a custom binding and a custom parameter attribute.
Custom parameter attribute is this:
public class ...
0
votes
0
answers
167
views
Issue with C# Web API 2 Date format in JSON
I am working on a large system that is using C# Web API 2 and Angular 12 on the front-end. Dates that are coming in via Oracle to C# are true dates in both systems (not strings).
They come across in ...
0
votes
0
answers
9
views
My webAPI redirect on http instead of https after AAD authentication
I have a problem with a webapi on .net 4.7.2 deployed on an Azure VM with ssl overloading.
After azure auth there is a redirect on http instead of https. I have to add https by hand to reload the page ...
0
votes
1
answer
234
views
Return JSON as a Treeview from parent-child SQL table
I need to return the table with paren-child hierarchy as a treeview json.
Googling gives vague code that seems way too complicated for this, or making something like this is supposed to be complicated?...