Has anyone come across something like this before? Basically, I have an action on a controller that merely queries the database via a repository pattern, adds some data to the ViewData then returns the View. But for some reason this action is being called 4 times per request.
The whole action itself is only about 10 lines long:
public ActionResult Details(int id, string slug) { Product p = productRepository.GetProduct(id); IEnumerable<Image> imgs = productRepository.GetImages(p.ProductId); if (imgs.Count() > 0) { ViewData['MainImage'] = imgs.First(); ViewData['Images'] = imgs; } Brand brand = productRepository.GetBrand(p.ProductId); ViewData['Brand'] = brand; var categories = productRepository.GetCategories(p.ProductId, true); ViewData['ProductCategories'] = categories; return View('Details', p); }
Also, the routes defined in my Global.asax are as follows:
routes.MapRoute( 'SlugsAfterId', '{controller}.mvc/{action}/{id}/{slug}', new { controller = 'Products', action = 'Browse', id = '' } ); // The default route that comes with ASP.NET MVC routes.MapRoute( 'Default', // Route name '{controller}.mvc/{action}/{id}', // URL with parameters new { controller = 'Home', action = 'Index', id = '' } // Parameter defaults );
Can anyone shed any light on this please? I am completely stumped.
Looks like those requests might be client-side requests like images, css or js files.