route-constraint

First call to Url.Action on a page is slow

怎甘沉沦 提交于 2019-12-06 02:05:36
问题 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 450ms (according to MiniProfiler) but that seems insanely slow. Subsequent calls to Url.Action are taking <1ms, which is more in line with what I would expect. This is consistent whether I use Url.Action("action", "controller") or Url.Action(

ASP.NET MVC Custom Route Constraints and Dependency Injection

青春壹個敷衍的年華 提交于 2019-12-04 08:00:31
On my ASP.NET MVC 3 App, I have a route constraint defined like below: public class CountryRouteConstraint : IRouteConstraint { private readonly ICountryRepository<Country> _countryRepo; public CountryRouteConstraint(ICountryRepository<Country> countryRepo) { _countryRepo = countryRepo; } public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { //do the database look-up here //return the result according the value you got from DB return true; } } I am using Ninject as IoC container on my app which implements

First call to Url.Action on a page is slow

允我心安 提交于 2019-12-04 05:16:10
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 450ms (according to MiniProfiler ) but that seems insanely slow. Subsequent calls to Url.Action are taking <1ms, which is more in line with what I would expect. This is consistent whether I use Url.Action("action", "controller") or Url.Action("action") , but doesn't seem to happen if I use Url.Content("~/controller/action") . This also happens when