mvcdonutcaching
mvcdonutcaching copied to clipboard
help,if custom RouteConfig,the 'area' parameter not work in asp.net mvc
file:App_Start/RouteConfig.cs
namespace XXXXXXX
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.LowercaseUrls = true;
routes.MapRoute(
name: "Default",
url: "{area}/{controller}/{action}/{id}",
//defaults: new { controller = "Default", action = "Index", area = "000000", id = UrlParameter.Optional },
defaults: new { controller = "Home", action = "Index", area = "000000", id = UrlParameter.Optional },
constraints: new { area = @"\d{6}" }
);
}
}
}
then
[DonutOutputCache(Duration = 300, VaryByCustom = "area")]
public ActionResult Index(int area)
{
return View();
}
then
- http://localhost/000000/home/index
- http://localhost/110000/home/index
it is not work,how to do?
any body the same question like me? I try to fix the question a lot of days ,but not work , headache!
Don't specify the VaryByCustom for area, MvcDonutCaching handles areas natively
thanks reply. it's not area ,it's like id, I have many url like
http://localhost/000000/home/index
http://localhost/110000/home/index
http://localhost/210000/home/index
http://localhost/310000/home/index
...
http://localhost/312345/home/index
you can new webapplication and copy the routeconfig , [DonutOutputCache(Duration = 300, VaryByCustom = "area")] to the home/index controller it is not work, change the 'area' to 'somecustomparm' is the same result
Just remove the VaryByCustom part dude, it has another meaning than the one you think
I have tried,not work .