Questions tagged [route-constraint]

20 questions
6
votes
3 answers

ASP.NET MVC Custom Route Constraints and Dependency Injection

On my ASP.NET MVC 3 App, I have a route constraint defined like below: public class CountryRouteConstraint : IRouteConstraint { private readonly ICountryRepository _countryRepo; public…
6
votes
3 answers

Does ASP.NET MVC have any DateTime route constraints?

does ASP.NET MVC contain any route contraints baked into the code? if so, how do i define a date-time constraint? eg. url: http://mydomain.com/{versionDate}/{controller}/{action} http://mydomain.com/2010-01-20/search/posts cheers :)
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
6
votes
4 answers

First call to Url.Action on a page is slow

I have a performance issue with a fairly simple ASP.MVC view. It's a log-on page that should be almost instant, but is taking about half a second. After a lot of digging it looks like the problem is the first call the Url.Action - it's taking around…
Keith
  • 150,284
  • 78
  • 298
  • 434
5
votes
3 answers

Route Constraint Error on POST

When you manipulate data in an action, you often receive an ID as param, but you need to do some error handling for that id. One of the error handling you have to do for every action is to make sure the ID is higher than 0 (not a negative number).…
Pierluc SS
  • 3,138
  • 7
  • 31
  • 44
4
votes
1 answer

Can i use a route constraint here?

If i have the following URL: /someurl And i have two domain names: us.foo.com au.foo.com I want this to 200 (match): us.foo.com/someurl But this to 404 (not match): au.foo.com/someurl The route looks like this: RouteTable.Routes.MapRoute( …
3
votes
1 answer

Mvc3 RouteConstraint - Session is null

In Mvc3 I created an own RouteConstraint class as I implemented the IRouteConstraint interface, which means that I implemented the Match function. The only but serious problem I have that whenever the Match function is called, the session object is…
Gabor
  • 31
  • 1
1
vote
0 answers

Manipulating RouteValueDictionary in RouteConstraint

Lets say I have a route; www.kunduz.com/stuff/something where "something" is being checked against a route constraint; public class AnalysisTypePathRouteConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route,…
Rudithus
  • 183
  • 13
1
vote
0 answers

Does Web API 2 support route constraints on query string parameters?

In Web API 2, I can put constraints in the route template; for example: [Route("api/foos/{id:int}")] void GetFooWithId(int id, [FromUri] string format = null) { ... } Is there a way to constrain query string parameters, such as format in the above…
1
vote
1 answer

Custom Route constraint called multiple times or called when no constraint mentioned at all

I have written a custom route but found that its called for Action methods which have not specified the constraints in the attribute routing. [RoutePrefix("api/v1/Orders")] public class OrdersController : BaseController { …
1
vote
1 answer

Does ASP.NET MVC have a Decimal route constraint baked in?

Does ASP.NET MVC have a decimal route constraint baked into the core library? I know there's the Regex Constraint but I was wondering if there's any others?
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
1
vote
1 answer

Cant define root route more than once in Rails 4

I've got the following in my routes file: scope :constraints => lambda{ |req| req.session[:user_id].present? } do root "users#show" end scope :constraints => lambda{ |req| req.session[:admin_id].present? } do root "brands#index" end root…
stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
1
vote
0 answers

Attribute Routing - Include Forward Slash in Parameter Consumed by IRouteConstraint?

I'm experimenting with attribute based routing - it's looking great but I have one problem. I've scoured the docs (attributerouting.net) and SO, but I can't figure out how to use a custom route constraint and pass in a parameter that includes a…
Martin Hansen Lennox
  • 2,837
  • 2
  • 23
  • 64
1
vote
1 answer

MVC3 Dynamic SubDomain Routing

First of all, I have read a lot of post relating this issue like: Asp.net MVC RouteBase and IoC , Tenant-specific routes for dynamically loaded modules , and many others. What I want is: - Dynamically create pages like tenant1.mydomain.com,…
gonzalomelov
  • 971
  • 1
  • 13
  • 30
0
votes
0 answers

The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'objectType'

I have an Optimizely 11.20 solution with controllers that use inline route constraints like this: `[Route(" {market:market}/{type:objectType}/{county?}/{municipality?}/{city?}/{mainDistrict?}/{district?}/{streetAddress?}", Name =…
0
votes
1 answer

How to use Route Constraint and Attribute Routing together?

I use Route Constraint in my website and Now I need to use Attribute Routing. Route Constraint class: public class BusConstraint : IRouteConstraint { private RouteDB routeDb = new RouteDB(); public bool Match(HttpContextBase…
hmahdavi
  • 2,250
  • 3
  • 38
  • 90
1
2