mvcdonutcaching icon indicating copy to clipboard operation
mvcdonutcaching copied to clipboard

help,if custom RouteConfig,the 'area' parameter not work in asp.net mvc

Open ma7x opened this issue 8 years ago • 5 comments

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?

ma7x avatar Oct 20 '15 01:10 ma7x

any body the same question like me? I try to fix the question a lot of days ,but not work , headache!

ma7x avatar Oct 20 '15 02:10 ma7x

Don't specify the VaryByCustom for area, MvcDonutCaching handles areas natively

moonpyk avatar Oct 20 '15 14:10 moonpyk

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

ma7x avatar Oct 21 '15 01:10 ma7x

Just remove the VaryByCustom part dude, it has another meaning than the one you think

moonpyk avatar Oct 21 '15 08:10 moonpyk

I have tried,not work .

ma7x avatar Oct 22 '15 01:10 ma7x