Questions tagged [attributerouting]

Define your routes using attributes on action methods in ASP.NET MVC and Web API.

NOTE: Attribute Routing support is currently built into Web API. You can read more information about it here: http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2

371 questions
5
votes
1 answer

How do I get rid of this error caused by MVCAttribute routing?

I have MVC Attribute routing enabled alongside Convention routing. I get this error every time I run the application. The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline…
5
votes
2 answers

Attribute routing not working in MVC4

I am using Attribute Routing in MVC4 application. I have set route to [Route("test-{testParam1}-{testParam2}")]. Here `{testParam2}' may consist the word 'test'. For example, if I enter a url as below, localhost:33333/test-temp-test-tempparam2 This…
DhavalR
  • 1,409
  • 3
  • 29
  • 57
5
votes
1 answer

Registering routes with ASP.Net 5's MVC 6 Attribute Routing

When using Attribute Routing in ASP.Net MVC 5 you would call the command routes.MapMvcAttributeRoutes(); and then just add the Route() tag to the Controller/Actions you wanted to build routes to. I am now trying to do this in ASP.Net MVC 6 and have…
Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123
5
votes
1 answer

ASP.NET MVC5 refuses to map a route which matches a physical path

When I debug/run, using IIS Express, and browse to http://localhost:1234/People, IIS Express tries to browse the People directory instead of executing the People route, and I get a 403.14 HTTP error. So I disabled the StaticFile handler in the…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
5
votes
1 answer

Asp.Net MVC5 - Html.Action - Attribute Routing - Weird Behaviour causing Exceptions

Here is some weird behaviour that is consistent across different actions and views in my entire website: Whenever I POST to some action method and Model.IsValid is false, I return the view. Whenever Html.Action() is called in the view that is…
5
votes
1 answer

Poor Performance And Slow Website With MVC 5 Attribute Routing

I am developing a website on Azure, with mvc5. I use attribute routing, with routes and route prefix on controllers. I call with action.link helper. I did not name my routes. I did the following on my route.config:…
5
votes
2 answers

ASP.Net MVC 4 w/ AttributeRouting and multiple RoutePrefix attributes

TL;DR I need a way to programtically choose which RoutePrefix is chosen when generating URLs based on the properties of a user in my MVC app Not TL;DR I have an MVC 4 app (with the AttributeRouting NuGet package) Due to the requirements of the…
Andrew Murphy
  • 221
  • 1
  • 3
  • 7
5
votes
1 answer

How to get route name from Attribute routing in ASP MVC5

Does anyone know how to get the route name from Attribute routing in a action filter? For example I have a controller and attribute route like this: [HttpGet] [CustomActionAttribute] [Route("~/index", Name="IndexPage")] public async…
Wei
  • 422
  • 1
  • 7
  • 15
5
votes
2 answers

Any way to override attribute on action method without having to override the whole method?

I'm using attribute routing in MVC 5, but I've began to notice a bit of a pain point. I have a situation where I want to subclass a controller because all the actions are going to do the same thing. However, I will obviously need to use different…
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
5
votes
1 answer

Optimize Performance or Attribute Routing and Routing table

I am working with Attribute Routing in asp.net mvc 4 web application. It is a single application that supports 15 different cultures and 20+ languages. The result of this, my routing table is extremely large, over 3000 routes. The main reason for so…
amateur
  • 43,371
  • 65
  • 192
  • 320
5
votes
2 answers

MVC AttributeRoute appears to be ignoring RoutePrefix and causing matching action in mutiple Controllers error

I am using the MVC Attribute Routing (MVC 5.1.2) and am running into the error: Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL. The request has found the…
Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123
5
votes
2 answers

OWIN cannot run multiple apps in isolation using webapp.start

When I try and start two apps on different url's, I get problems with attribute routing middleware. If I have two similar routes in seperate apps but with different http methods web.api seems find only one of the…
AndyD
  • 5,252
  • 35
  • 32
5
votes
1 answer

Restrict attribute routes to specific HTTP verbs

With the AttributeRouting library I can restrict a route to a specific verb: [Route("customers", HttpVerbs.Post)] In MVC 5 AttributeRouting is built in, but there is no overload taking HttpVerbs. How do I restrict a route to POST in this case?
CMircea
  • 3,543
  • 2
  • 36
  • 58
5
votes
2 answers

Using HttpClient to Send Dates in URL Using AttributeRouting

I'm having some problems getting a date range query accepted by my WebAPI. As as far as I can tell from everything I've read this should be working but I still get 400 Bad Request responses. My API route looks like this: …
Jammer
  • 9,969
  • 11
  • 68
  • 115
5
votes
1 answer

405 when using AttributeRouting.PUTAttribute unless I also include HttpPutAttribute

We have an MVC project that I am attempting to update to include WebApi. In order to get the required routes we are using AttributeRouting. All the calls seem to be routing correctly except for [PUT] which returns a 405. I have simplified the…
Thad
  • 1,518
  • 2
  • 21
  • 37