Questions tagged [routeattribute]

24 questions
9
votes
2 answers

WebApi2 Attribute Routing 404

I upgraded an existing MVC4/WebAPI1 project to MVC5/WebAPI2 in Visual Studio 2012 as described here. The site worked as expected. I then followed the directions for attribute based routing found here - except I keep getting a 404 for the…
Jamie Dixon
  • 4,204
  • 4
  • 25
  • 47
8
votes
2 answers

How to add MessageHandler for a specific controller that is using Routing Attributes in ASP.NET WebAPI 2?

It is possible to add a MessageHandler only for a specific controller that is using Route Attributes? I want to cut the request earlier in the pipeline if it doesn't contain certain headers. I want to mention that: I can't add another route in…
8
votes
2 answers

The route template cannot start with a '/' or > '~' character and it cannot contain a '?' character

I am getting the an exception with the following route attribute: [Route("{id}?action=decline")] Exception: An exception of type 'System.ArgumentException' occurred in System.Web.Http.dll but was not handled in user code Additional information:…
Dave New
  • 38,496
  • 59
  • 215
  • 394
6
votes
0 answers

How to add some RouteData for MapMvcAttributeRoutes?

I'm building a multi-tenant website and I use both MapMvcAttributeRoutes and the standard MapRoute in my application. I also use this code to get the subdomain name successfully when I'm in a controller that doesn't use the RouteAttribute. I can't…
David Létourneau
  • 1,250
  • 2
  • 19
  • 39
5
votes
1 answer

ASP.NET MVC 5: Define route order across controllers (RouteAttribute)

The RouteAttribute("abc", Order = 2) ordering only seems to be respected within a controller: when the following methods are defined in the same controller I get the expected behavior, i.e., Method1 takes priority, Method2 is never…
2
votes
1 answer

.net core webapi route attribute regex with /

I am trying to find a way to match a route when request contains multiple path and URL always end with /end For example: domain.com/api/path1/path2/path3/end domain.com/api/path1/path2/path3/path4/end I tried…
duongthaiha
  • 855
  • 6
  • 17
2
votes
3 answers

RedirectToAction generates wrong url (querystring parameter instead of routedata param)

I am using RouteAttributes in my projects, and they are working correctly, except in this case: I have two similar actions, one accepting two int parameters, and the other accepting just one. The first one takes the two parameters and uses them to…
1
vote
1 answer

Blazor route attribute with page parameters and localization

I'm a long time hobby developer, and recently started playing around with Blazor. The initial issue I was working with today was how to localize the route name. I found a solution for it replacing @page "/whatever" with @attribute…
1
vote
1 answer

RouteAttribute is missing

I am using Microsoft ASP.NET Web API 2.2 in a web application. A controller looks like this: public class EventsController: ApiController { [HttpGet] [Route("GetAllActivities")] public IEnumerable GetEvents() { /* stuff */ …
Anders Lindén
  • 6,839
  • 11
  • 56
  • 109
1
vote
1 answer

Route to action can not be found with route attribute in asp.net mvc

I use asp.net mvc with route attributing and I get this error: System.Web.HttpException (0x80004005): No matching action was found on controller 'Test.RequestController'. This can happen when a controller uses RouteAttribute for routing, but no…
HelloWorld
  • 4,671
  • 12
  • 46
  • 78
1
vote
2 answers

Route attributes for areas confusion when published on host in asp.net mvc 5

I am using route attributes with areas. My route config is : public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); routes.MapRoute( …
1
vote
2 answers

MVC5 Attribute Routing

I am trying to use Route Attributes to define the MVC Routing. I have got the following code in the Controller.. [Route("MDT/Detail/{id}")] public JsonResult Detail(int? id) { ITS.Models.ComputerDetail cp = GetDataFromDatabase(id.Value); …
TTCG
  • 8,805
  • 31
  • 93
  • 141
1
vote
1 answer

Route is not triggerd with Attribute Routing and FromUri

I want to trigger the below route with this url: http://localhost:66777/api/productdetails?articlegroup=1&producedat=2012-01-01 What is wrong with my - I guess - Route…
Pascal
  • 12,265
  • 25
  • 103
  • 195
1
vote
0 answers

ASP MVC Internalization Links - Change Language Links

I've some localised routes. For this i mark my routes with asp mvc route attribtues and afterwards i clone them for each language with translated values and a language data token and a constraint which checks the culture / language. for…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
0
votes
0 answers

Using "api" in RoutePrefix Attribute in an MVC Controller causes errors, works with ApiController

This might be a weird question, but I struggled for hours with this issue and at the end I have no idea what is happening and feel like I fundamentally misunderstood something about all of this. Following…
1
2