As of May 31, 2023, we have updated our Code of Conduct.

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

Store logs in file if logging in database fails

I was working on Logging using Serilog in .net core web api 7. Logs are successfully getting stored in database But my question is, if database logging fails then that log should get stored in a file ...
Vaishnavi's user avatar
0 votes
0 answers
34 views

Flutter: can't connect to localhost API

i have this kind of prob, i want integrate Flutter with .Net core web API. im new to flutter so, i just followed the tutorial but the i cant connected to localhost api import 'dart:convert'; import '...
ayman's user avatar
  • 43
0 votes
0 answers
8 views

Gridview is overflowing the page. How to fit it to 100% of page

I am trying all ways to fit my gridview into screen, but it is exceeding the screen Text is aligned in center. I wanted it to be aligned from the start Columns "Main Group" and "Sub ...
Chetan Kulkarni's user avatar
0 votes
0 answers
31 views

How to show the actual error message instead of custom error when using Web API 2?

I have build my API using ASP.NET web API 2 and am using WebAPiThrottle to throttle the requests, as shown below: public static void Register(HttpConfiguration config) { // more code... config....
Hooman Bahreini's user avatar
0 votes
0 answers
18 views

How do i can seed the data?

I have a following survey class: public class SurveyEntity : IIdentity<int> { public int Id { get; set; } public string Title { get; set; } public string Status { get; set; } ...
Ptrk12's user avatar
  • 15
0 votes
0 answers
43 views

Is there any alternative to app.CreatePerOwinContext() method for .NET Core 6?

I'm migrating my ASP.NET MVC web application to .NET (Core) 6. While porting identity, I'm facing a blocker issue and I got stuck here. Existing ASP.NET MVC app uses this code: public void ...
Aman Tiwari's user avatar
0 votes
1 answer
10 views

In Web API 2, how can I determine which action will be invoked in Application_PostResolveRequestCache?

I'm trying to figure out what data I need to provide ApiControllerActionSelector.SelectAction(controllerContext) with in order to accurately determine the action that will be invoked. I need to do ...
Matt Mills's user avatar
  • 8,642
0 votes
1 answer
58 views

How to use MudDateRangePicker in blazor server using web api

I want to filter or search the DATE from this (date) to this (date) using MudDateRangePicker in MudBlazor in my database. I get a bad request, and there seems to be an error in my code. Can someone ...
Xlayer's user avatar
  • 17
0 votes
0 answers
55 views

Microsoft Owin Hosting only accessible from localhost - from public ip not accessible

I'm using aws Windows Server 2022 Datacenter build 21H2. trying to host owin with webapi. My pc os is windows 10 .net framework 4.8 webapi only reachable from localhost:port/endpoint. Not able to ...
Venkat B's user avatar
0 votes
2 answers
125 views

How to return Json result with 404 status code

I am using ASP.NET Web API 2 and I want to return a json result from my API with the error code 404. I am trying to mimic this result: This is what I have tried: [RoutePrefix("error")] ...
Hooman Bahreini's user avatar
0 votes
0 answers
12 views

How to replace error page for Web API application on mono

I'm working on moving an existing Web API from IIS to NGINX with Mono and I'm stuck on default error pages: whatever I do, I still get default one, which exposes confidential data: system, ASP.NET ...
Marius's user avatar
  • 1
1 vote
0 answers
78 views

Autofac Integration with self hosted Owin server returns 404 for all WebApi controllers with dependencies

Overview We have a solution that we are switching from ninject to autofac for DI. We have a console application (.net 4.8) that starts two separate processes for testing locally. It starts an owin web ...
DanCaveman's user avatar
0 votes
1 answer
56 views

FileActionResult returns a corrupt file

I have download (pdf) file feature in our app and this was implemented months ago, if not longer. It always worked fine but I haven't used it in some time so I don't know when the problem started to ...
Thierry's user avatar
  • 6,072
1 vote
1 answer
31 views

How to handle when user clicks on button 100 times (web api services involved)

Recently I faced an interview on WEBAPI. The interviewer asked that when the user clicks continuously on the button, assume that 100 times. In that case, will 100 requests hit the server? How to ...
user768853's user avatar
1 vote
1 answer
105 views

How to provide model documentation and example value using Swashbuckle?

I have created an API method using Web API 2 (MVC 5), as shown below: /// <summary> /// Import all of the jobs for the given organisation. This method assumes that all of the organisation's ...
Hooman Bahreini's user avatar
0 votes
0 answers
49 views

Authentication failed - OWIN - OAuth - Webapi 2.0

I have created a WebAPI 2.0 service and a Windows Forms client. I can create a valid token request by the client. But when I try to use that bearer token for accessing the WebAPI I get the following ...
Michael's user avatar
  • 189
1 vote
1 answer
136 views

Add new API version to ASP.NET Core Swagger docs

I have an API and associated Swagger docs I have an ASP.NET Core 7 API project, wired up to produce Swagger documentation. The pertinent initialization code, in Program.cs, looks like this: // ...
Bob.at.Indigo.Health's user avatar
0 votes
0 answers
5 views

WEB API Post method Save Method [FromBody] emp object, It is working fine if we pass 3rd parameter as well but emp have only 2 parameters

EMP Json data working fine for more parameters then EMP object. It should give 200 response only for those parameters passed , if more or less parameters it should give 400 bad response
user3939864's user avatar
0 votes
0 answers
30 views

What is the best way to updates multiple records using list in Web API

I have controller method which accepts a list of employees and then call to data access layer method to update employees record one by one from list. This is causing slow down in performance of API. ...
user avatar
-1 votes
3 answers
74 views

Why is my .net Core API Attribute Routing not working?

I am experimenting with a "Hosted Blazor WASM" project. This problem does not concern the Blazor client router (that is working fine). This concerns the "server-side" router not ...
Julian Dormon's user avatar
0 votes
0 answers
25 views

Asp Dotnet 6 - Angular: Storing login data problem

i am having a problem when using session with Asp backend and Angular frontend to store login data when login from angular: Here is my controller, the login param is just simply email and password: ...
FalAn's user avatar
  • 35
0 votes
1 answer
326 views

ASP.NET Web API 2 - [FromBody] is null

I have a really simple test app to send over a json Post to my web services. Everything is working expect for some reason the value received in the Post([FromBody] string value) is null. // POST api/&...
JL1's user avatar
  • 303
0 votes
0 answers
60 views

Grid not populating data from WebAPI in Angular data grid

I'm new at angular, and implementing a basic data grid which takes data from an API. The data is being logged in the console, but when I pass it as row data in the grid, it does not populate there. If ...
Shivansh Trigunait's user avatar
0 votes
0 answers
63 views

How to allow basic authentication on a single WebAPI endpoint in an MVC 5 app employing OpenID (ADFS)

I have a web application, hosted on our organization's web servers, which uses OpenID Connect (OIDC) in the shape of Active Directory Federated Services (ADFS) for authentication. It previously used ...
Philip Stratford's user avatar
0 votes
1 answer
118 views

Calling API in Parallel using C#

I have gone through many Stackoverflow threads but I am still not sure why this is taking so long. I am using VS 2022 and it's a console app and the target is .NET 6.0. There is just one file Program....
hillcountry99's user avatar
1 vote
0 answers
17 views

Unable to add Token Providers when using multiple Identity Types

My application has two separate identity types. I created two types, as opposed to simply using roles, because the information I have to save about the types are pretty drastically different, and they ...
T-Rev's user avatar
  • 92
0 votes
1 answer
55 views

IIS-Hosted WebAPI Stops Processing RabbitMQ-Queued Messages

I have a C# WebAPI that is hosted in IIS that listens to a RabbitMQ queue. When the Application Pool is started, it seems the processing of queued messages functions as expected. After a period of ...
Flea's user avatar
  • 1,480
0 votes
0 answers
21 views

Web API 2 TypeConverter and routing problem

Preamble My problem is already discussed in a similar way in several other posts on stackoverflow. But I just can get it done to put all together. Maybe because it isn't really possible to do so in ...
MiGro's user avatar
  • 471
0 votes
1 answer
180 views

My web api get 500 internal server after deploy to azure api management

I am new to azure app service, i have used visual studio to deploy my web api to azure api management. i am doing a mobile application project, I need to make local ssms database data sync to azure ...
user avatar
1 vote
0 answers
121 views

Display nodes in swagger whose values are returning null

I have following JSON format and data, and in few nodes I am getting null values. Check below JSON data. In Swagger that nodes are not displaying whose values are null in get request. For example ...
Nic's user avatar
  • 409
0 votes
0 answers
34 views

Body is not deserialize from powershell call

I have an error with powershell api call. This is my powershell code : $body='[{"Criteres":[{"Nom":"Code","Valeur":"lyon"},{"Nom":"...
user1069516's user avatar
0 votes
0 answers
246 views

In ASP.NET 4.8, how can I deserilize a file containing JSON, uploaded as POST multipart/form-data request to an object in memory (no file on server)?

Example code: I export an object as JSON in a file [HttpGet] public IHttpActionResult ExportObjectToFile() { var exampleObject = new ExampleObject(); var response = Request.CreateResponse(...
Nomnom's user avatar
  • 4,033
0 votes
0 answers
75 views

.Net Framework 4.7 - HttpClientFactory to use data from the current request context

Web API C# .NET Framework 4.7.2 Unfortunately it is not possible to use NET CORE. I have to do something a lot like: Configure HttpClientFactory to use data from the current request context my ...
Fede's user avatar
  • 9
-1 votes
2 answers
778 views

Join two tables (One to Many) using asp.net core web api

I am new at C# entity framework. I am trying to build an API, but stuck in retrieving data from relational table. I have a Game table in MS SQL database, where GameId is the primary key. I have ...
Basit's user avatar
  • 1
-1 votes
1 answer
509 views

Why I get ArgumentException: Could not cast or convert from System.String to ..?

I got this error: ArgumentException: Could not cast or convert from System.String to gsMedicApp.Pages.Ricoverato. This is my code public class Ricoverato { public int id { get; set; } ...
stighy's user avatar
  • 7,973
0 votes
0 answers
27 views

How to google gocs api to create google doc file and upload it to drive in .net web application?

I want to create a new google docs file from existing document and need to upload that file to google drive. How we can achieve this in .net web application using google docs api? Also want to display ...
Vijay Rathod's user avatar
0 votes
0 answers
12 views

Installing Swashbuckle causes System.Web.Http assembly mismatch

I have a AspNet WebApi using .NetFramework 7.2, and I am trying to add Swagger to it using Swashbuckle as per this link: https://github.com/domaindrivendev/Swashbuckle.WebApi. The problem is that the ...
user2399378's user avatar
0 votes
0 answers
98 views

.NET 6 Web API - Not getting uniform error response for Authorization using Swagger in Mozilla, Chrome, Edge

I am using Windows authentication to validate a user trying to consume my .NET 6 Web API, This is in Chrome, Response headers look like, cache-control: no-cache,no-store content-type: application/...
tRuEsAtM's user avatar
  • 3,487
0 votes
0 answers
48 views

How to send null value to Web API endpoint

I have an endpoint like the following. The signature allows id2 to be null. If I call this endpoint from Postman or a front end application and omit id2 I get a 404 not found error. How could I ...
Rich's user avatar
  • 6,428
1 vote
1 answer
356 views

JSON value deserialize to C# Object in .NET Core

I am trying to get the data from API (https://localhost:7270/api/GetEmployees). After getting all required data from the API I just want to deserialize into a C# Object and need to show in HTML page. ...
Sanda Dharmarathna's user avatar
0 votes
1 answer
812 views

.NET 6 Web API - Validate JSON Request Body to generate uniform Error response

I want to validate my JSON request body to provide a uniform error response. Currently, if there is an invalid character in JSON Body, then I get, { "type": "https://tools.ietf.org/...
tRuEsAtM's user avatar
  • 3,487
2 votes
1 answer
49 views

Get all parameters in url

I have to create a WebAPI which fit the URL : http://server/share/pa/repos?file=Ring#filter=path|/A6/ERE/50-001| and get elements into pipes => "ERE" and "50-001" I tried this :...
papoxe's user avatar
  • 53
0 votes
0 answers
49 views

Web API in an MVC project not working after publishing but it is working in localhost

I have added web api 2 controller in mvc project and it is not working after publishing but it is working in localhost. enter image description here
Srikanth Sunny's user avatar
1 vote
1 answer
706 views

Handle CORS HTTP Options Preflight Request in a .NET 6 Minimal API?

Can't seem to figure out how to handle a CORS Options (preflight) request in a minimal API in .NET 6. While there is a MapGet and MapPost for routing, there is not a MapOptions specifically. We do ...
David Mays's user avatar
0 votes
1 answer
80 views

How to apply a loop when inserting a record?

I am building a form to register assets in a database, the assets are repeated many times for that reason I created an input where I store the number of assets so that the user can enter n number of ...
I'm newbie's user avatar
0 votes
1 answer
125 views

async jQuery ajax method always posting null data to API

I wanted to take advantage of async in JavaScript, but the function will simply not POST the data to the API (it's ALWAYS null, be it a simple variable or an object). I've scoured around the ...
MC9000's user avatar
  • 1,952
0 votes
1 answer
565 views

Postman won't POST to ASP.Net WebAPI 2 controller, but GET works

I can't seem to get my webapi to work in PostMan and it gives me a 404 when POSTing, but works only when using GET (even though the api specifically set to accept only POSTs! - go figure!) Here's the ...
MC9000's user avatar
  • 1,952
0 votes
2 answers
143 views

How to pass 2 variables from jquery AJAX to ASP.Net WebApi2 method?

I can write a JQuery AJAX call to a webapi2 (asp.net) controller with only 1 parameter just fine (one json object), but when attempting to send 2 parameters (a string and an integer) to a call with ...
MC9000's user avatar
  • 1,952
0 votes
1 answer
64 views

Which controllers type should I use in asp.net web api?

I am creating an asp.net web api project, I am storing my data in mssql server db, and I am using an Entity Framework. I was following the microsoft guide (https://learn.microsoft.com/en-us/aspnet/...
Palamar66's user avatar
  • 212
0 votes
0 answers
63 views

IAutofacExceptionFilter OnExceptionAsync not firing when unhandled exception thrown

I have a Web API 2 application that I am working on. I tried establishing a global exception handler/logger using the article here, but nothing I tried worked at all. I use Autofac, found out that ...
DerHaifisch's user avatar

1
2 3 4 5
154