Questions tagged [asp.net-web-api-routing]

Questions about routing within ASP.NET Web API framework

Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

ASP.NET Core 7 Web API : date serialization for Angular form control

I've been scouring Stack Overflow and the web in general, but I can't seem to find a straight answer. In the Person class, Birthday is defined as DateTime. public class Person { public string Name ...
FunkMonkey33's user avatar
  • 1,981
0 votes
1 answer
15 views

How to use RoutePrefix in sub folders in Controller folder in .net core 6 Web API Application?

I am trying to call controller action in subfolder located in main Controller folder. I changed RoutePrefix in controller and app.MapControllerRoute() in program.cs different ways. But my postman call ...
NeoDotNet's user avatar
0 votes
2 answers
76 views

How do I set a prefix in my ASP.NET Core 7 Web API for all endpoints?

I am retrieving a string from my appsettings.json: { "ConnectionStrings": { //several strings }, "BaseRoute": { "Base": "/myapi/" } } And I ...
Pieter Dreissen's user avatar
0 votes
1 answer
34 views

API Upgrade from .Net Framework to .Net 6.0 throwing 404 error in Postman

I have the following code which was working fine in .Net Framework but after upgrade it's throwing 404 error. This is basically my code : [RoutePrefix("API")] [BasicAuthenticationFilter] ...
TheFallenOne's user avatar
  • 1,608
0 votes
0 answers
28 views

How do I let users define the URL for a controller in my ASP.NET Core library?

I'm writing a library for a project, and in this library, I would like to add a controller so that other APIs can make requests, but I would like that the person that is using my library can define ...
Pedro's user avatar
  • 3
0 votes
0 answers
17 views

Multiple optional parameters with in-between empty parameters in Web API attribute routing

This is in .NET 6 The Action method: [HttpGet("GetCustomers/{customerName?}/{customerNumber?}/{customerSignature?}")] public async Task<IEnumerable<Customer>> GetCustomers(string ...
Nands's user avatar
  • 379
0 votes
0 answers
248 views

Defining API route using API versioning in ASP.NET Core 7 Web API

I am currently working on an ASP.NET Core 7 Web API project and I am facing an issue with defining the API route using API versioning. Program.cs builder.Services.AddSwaggerGen(c => { ...
Rakesh Kumar's user avatar
  • 2,731
0 votes
0 answers
36 views

Web Api 1 | .NET 4.5.2. | routing with http verbs instead of actions, without external libraries

I'm not finding this info anywhere on MSDN, SO, other sites, and i've been searching for days. I'm on a WEB API 1 - .NET 4.5.2 project, and i need to expose a CRUD controller. This means I can't use ...
strongmmc's user avatar
  • 137
0 votes
1 answer
60 views

AmbiguousMatchException when truing override parent ASP.NET controller

almighty All! Second day passed... Need Help! I have two controllers: base DocumentController and derived InvoiceController in ASP.NET C# WebAPI application**:** [ApiController] [Route("Documents&...
Sergey  Khachaturov's user avatar
-1 votes
3 answers
125 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
-1 votes
1 answer
382 views

Multiple routes with and without version for the same controller in .NET Core is not working

I want to create two routes, one with version and another without, to point to the same controller without decorating the controller methods. I have defined two routes at the top of the controller, ...
RedRose's user avatar
  • 555
0 votes
0 answers
41 views

How do I create a custom verb for an ASP.NET Web API?

My original problem is that my GET request was being rejected for the parameters being too long. So I thought, oh I'll just POST the parameter that's getting too long. Well that doesn't work because ...
Andrew's user avatar
  • 1,591
1 vote
1 answer
51 views

Why is PUT throwing an Error 400 in my WebAPI?

First time working with web APIs and I can't seem to make the PUT method work, while everything works fine (get, post and delete). I'm trying to do, what I think it is, a very simple call to update ...
Lucas Hoffmann's user avatar
0 votes
1 answer
39 views

NGINX giving 404's, never proxy passes to fastcgi-mono-server4

Working on getting a skeleton of ASP.Net application running on Ubuntu. Installed all the requisite applications. Just trying to serve index.html or index.aspx to start. However, running through Nginx ...
LiteWait's user avatar
  • 584
1 vote
1 answer
317 views

Asp.Versioning.Http AmbiguousMatchException: The request matched multiple endpoints on controllers

I am trying to achieve header based versioning on my controllers with Asp.Versioning.Http package version 6.4.0 it is supposed to be super simple here however i get AmbiguousMatchException: The ...
TheSlowestDev's user avatar
0 votes
0 answers
424 views

ASP.NET Core Web API : my api works on localhost but not on my plesk webserver

I have build an ASP.NET Core Web API and it's working fine on my machine testing it with postmann, all is beautiful, but when I put it in production on my plesk web server, it always says error 404 ...
sauro1997's user avatar
0 votes
1 answer
464 views

.Net 6 Web API: Multiple Base Routes AND Named Routes

I'm working on converting an ASP.NET Web API 2 to a .Net 6 Web API and ran into a problem when using Versioning. The problem I'm running into concerns named routes. I want my API to be able to be ...
RoLYroLLs's user avatar
  • 3,113
0 votes
1 answer
2k views

c# .net core api controller mixing route parameters and query parameters

I have a url (that I can't really modify) that has id as part of the route and then a start date and end date as query parameters. I'm not sure how to mix route parameters and query parameters and ...
Bryan Dellinger's user avatar
2 votes
1 answer
1k views

MapControllers not finding ApiControllers in class library

In .NET 5 this was working, but since moving to .NET 6 and using the more minimal WebApplication to spin up a REST API, I've hit a wall. To replicate this, I create a simple .NET 6 Console App and in ...
jtalarico's user avatar
  • 906
0 votes
0 answers
29 views

WebAPI routing with / in

On my WebAPI .Net Framework 4.8 I have a WebAPI method with this route : [Route("gdoc/a/G1/{code}/{path}/child")] This route doesn't fully work because {path} value contains caracters "...
papoxe's user avatar
  • 53
0 votes
1 answer
493 views

Multiple ApiControllers for ASP.NET Core Web API

I have been trying to figure out how to use multiple [Route("[Controller]")] attributes in my two controller files. From what I have looked it up it seems possible, and even MS docs say you ...
JustBarnt's user avatar
  • 104
1 vote
1 answer
516 views

POST method endpoint not being hit but GET method endpoint works fine

I can't seem to reach an endpoint using the POST method but the very same endpoint works fine when using the endpoint as a GET method. I have mentioned two endpoints below, one of which is a GET ...
Luky's user avatar
  • 11
0 votes
2 answers
810 views

HttpGet route not found

I have built a controller. For some unknown reason the end point is not reached. Unfortunately I do not understand why. [Route("api/realestates")] [ApiController] public class ...
Taladan's user avatar
  • 429
0 votes
0 answers
1k views

What's wrong with these redirects in .NET 6.0?

I have this controller/action: using Microsoft.AspNetCore.Mvc; namespace WebService.Controllers { [Route("api/[controller]")] [ApiController] public class PageController : ...
noontz's user avatar
  • 1,794
0 votes
1 answer
90 views

Route that automatically gets name from webapi action

I have ApiController that looks like [RoutePrefix("Companies")] public class CompanyController : ApiController { [HttpGet] [Route("GetCompanyProfile")] public ...
Anders Lindén's user avatar
0 votes
0 answers
662 views

ASP.NET Web API duplicate endpoints

In my ASP.NET web application I have two types of controllers: 1) Web API controllers: 'System.Web.Http.ApiController' 2) Odata controllers: 'Microsoft.AspNet.OData.ODataController' I have a problem ...
lukas1987's user avatar
-1 votes
1 answer
1k views

How to call HTTP POST method from another Controller which Have a HTTP GET method in WEB API 2

I am working on a project which have scenario to redirect to httppost method from another controller which have a httpget method. Can you guys suggest me a good approach to achieve it? Example is ...
Arun Singh's user avatar
1 vote
3 answers
2k views

How to set default versioning in ASP.NET Core 6 Web API for my scenario?

Just realised that my understanding about ASP.NET Core 6 Web API versioning is wrong. This is my controller: [ApiVersion("1.0")] [ApiController] [Authorize] public class FundController { ...
daxu's user avatar
  • 3,544
1 vote
0 answers
138 views

WebAPI: Make operation method enabled/visible only for minimum/maxium API version

I have a simple WebAPI controller, looks like this: [Authorize] [ApiController] [Route("v{version:apiVersion}/[controller]")] [Route("[controller]")] [ApiVersion("1.0")] [...
user1470240's user avatar
7 votes
2 answers
3k views

HttpGetAttribute name property not working for routing

I have a WebAPI controller named WeatherForecast with one operation. The operation method looks like follow: [HttpGet(Name = "GetWeatherForecast")] public IEnumerable<WeatherForecast> ...
user1470240's user avatar
1 vote
1 answer
492 views

Web API partially (start with) match route in Controller

How can I map multiple urls to one action method? For example http://localhost:10000/api/ABC and http://localhost:10000/api/ABCDCD will map to same action name because both starts with ABC. I can't ...
user781700's user avatar
3 votes
1 answer
4k views

API Controller Routing in .NET 6 Doesn't Work Any More

I'm trying to create a standard WebAPI project in .NET 6. I notice that the standard ApiController route doesn't have the leading api route that I like to have. When I add it, the controller breaks. ...
Daniel Przybylski's user avatar
0 votes
1 answer
645 views

Blazor WASM api call gets 404 on POST but 200 on GET

I'm working on a Blazor WASM project, and I have a page that needs to post a file to the server. So I wrote something like this: @page "/Test" @inject HttpClient httpClient <h4>Please ...
Brian's user avatar
  • 137
0 votes
0 answers
132 views

Unexplained delay in ASP.NET WebAPI in hop from web app directory to action route

Under an 'apps' web site, we've created a web application through docker/powershell using: New-WebApplication -Name 'service_b' -Site 'apps' -PhysicalPath 'C:\ServiceB.API' -ApplicationPool '...
Triynko's user avatar
  • 18.8k
0 votes
0 answers
64 views

Model binding for number with trailing whitespace

I have a web api controller with HttpGet method inside. The controller sets it's route in a parametrized RouteAttribute (catalogId doesn't have :int or :long rules by an intention). The controller's ...
Dmitriy's user avatar
  • 654
0 votes
1 answer
181 views

ASP.NET Web Site Not Allowing Axios PUT Access (405 Method Not Allowed)

I've got a controller set up and working for all of my GET requests, but when it comes to the PUT requests my Web Site (not a Web App, if that makes any difference) is returning a 405. I've got the ...
Scott Baker's user avatar
0 votes
1 answer
462 views

Web API 2 Generic route with every controller

I am working on web api 2.0 and trying to achieve below url to access with every controller. I have created a base controller which I inherited to every controller. Now I have a scenario where I need ...
Arun Singh's user avatar
1 vote
0 answers
388 views

REST style API returns 404 when identifier value contains special characters

We have a Web API endpoint defined as follows: [RoutePrefix("orders")] public class OrdersStatusController : ApiController { [HttpGet, Route("{referenceId}/status")] public ...
Craig W.'s user avatar
  • 17.9k
-1 votes
2 answers
2k views

Pass url path as param in web api endpoint

I have this controller with one method which receives two variables. One is the culture, the other is a path. public class WebsiteContentController : ApiController { [HttpGet] public ...
LucaCosta's user avatar
0 votes
1 answer
1k views

ASP.NET MVC GET request with multiple optional filter query params

Im trying to create a GET request that can handle few optional searching/filter params. The request should look like: https://localhost:99999/api/computers?ModelName=asus&RAM=2&ScreenSize=22 ...
David Axelrod's user avatar
1 vote
1 answer
207 views

.Net Core Web API Request Redirecting

I have controllers AController and BController and both of them has a method that name is upload. This is the sample code; public class AController : ControllerBase { [HttpPost("[action]"...
doğan 's user avatar
  • 339
1 vote
0 answers
82 views

Is there a Best Practice for multiple Http Post - RPC style, custom MediaTypeFormatter or Other

I'm not looking to start a holy war but looking for maybe a document on best practices for creating APIs which contain multiple HTTP verbs. I inherited a 4.7.2 Web API project and trying to straighten ...
Dave's user avatar
  • 11
0 votes
0 answers
346 views

Program.cs Main Function is not hit when Asp.NET core 5 web api

Hello I'm getting a problem not getting hit into Program.cs . We converted this project from previous .NET core . Now we are using latest .NET core 5 web api . I think when the first application run ...
Rifat Murtuza's user avatar
1 vote
1 answer
34 views

WebAPI URL is not routing as expected

I have the following two methods defined in my WebAPI controller: public class SocketController : ApiController { [HttpGet] [Route("api/socket")] public List<SocketInfo> ...
Yossi G.'s user avatar
  • 939
0 votes
1 answer
315 views

Url matching difference in ASP.NET Web API vs ASP.NET Core

I am trying to find the difference in terms of how URL matching is different in both these frameworks I know the following is true for ASP.Net Web API, would like to know is it true for ASP.NET core ...
Rishi Tiwari's user avatar
  • 1,041
0 votes
1 answer
88 views

WebApi POST with additional parameters

I am using WebAPI2 .NET5 to create a controller that Inserts records into our database. I would like to know if it is possible to pass additional parameters to the HttpPOST method ? I specifically ...
Mable's user avatar
  • 13
0 votes
1 answer
2k views

unable to setup swagger UI in WEB API .net framework project

i have SwaggerConfig Setup like this public class SwaggerConfig { public static void Register() { var thisAssembly = typeof(SwaggerConfig).Assembly; GlobalConfiguration....
Raas Masood's user avatar
  • 1,475
0 votes
1 answer
218 views

.NET Core 3.1/5 Api Querystring parameters do not work

I have noticed something strange with my .Net Core 3.1 and .Net Core 5 Apis. When there are 2 different GET methods to retrieve all records and a single record by id, route based parameters work but ...
Lee Z's user avatar
  • 802
0 votes
2 answers
811 views

Include placeholder in API base path .net core

Wondering how you would go about including a placeholder/variable in the API base path, you would see something like this used in azure devops for example: https://dev.azure.com/{company-name}/. How ...
Shaun's user avatar
  • 55
0 votes
0 answers
263 views

Error hosting web API in Blazor server web application

We have an existing .NET 5.0 Blazor web application. I have added an ASP.NET Core Web API to the same project because I want to provide a REST interface to external consumers. When I request http://...
Ajit Goel's user avatar
  • 4,190

1
2 3 4 5
21