ASP.NET MVC控制器操作每个请求执行4次

Ian*_*ley 2 asp.net asp.net-mvc firebug

以前有没有人遇到这样的事情?基本上,我在控制器上有一个动作,它只是通过存储库模式查询数据库,将一些数据添加到ViewData然后返回视图.但由于某种原因,每个请求被调用4次.

整个行动本身只有10行左右:

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);
}
Run Code Online (Sandbox Code Playgroud)

此外,我的Global.asax中定义的路由如下:

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
);
Run Code Online (Sandbox Code Playgroud)

有人可以对此有所了解吗?我完全难过了.

Cha*_*ran 7

看起来这些请求可能是客户端请求,如images,css或js文件.