我对MVC局部视图的搜索顺序感到困惑。
例如,来自d:\ mysite的我的网站网址是: http://localhost:8039/Admin/Contents/Create/FundswireArticle
没有名为d:\ mysite \ Admin或d:\ mysite \ Admin \ Contents的物理文件夹(它们通过路由到其他一些地方来控制)。
从文件监视器,我实际上看到我的应用程序试图找到 d:\ mysite \ Admin和d:\ mysite \ Admin,它无法找到它(因为它不存在),然后它就会使用路由。
这是MVC的正常行为(我在.net 4.5下运行)?
答案 0 :(得分:0)
现在看起来这是MVC的正常行为。我将测试代码简化为:
routes.MapRoute(
name: "Test",
url: "{Test}/{Index}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
要访问的网址是:http://localhost:6666/Test/Index 您可以看到路由将流量路由到Home Controller。
从文件监视器,我看到了这些:
请求文件d:\ testspeed \ Test
请求文件d:\ testspeed \ Test \ Web.config
请求文件d:\ testspeed \ Test \ Index
请求文件d:\ testspeed \ Test \ Index \ Web.config
由于没有测试文件夹,所有请求都失败了。 然后它去读取bin文件夹中的所有dll,web donfigs然后加载 主文件夹和所有javascripts。
这个演示在契约MVC中将搜索url中提到的具有相同名称的物理文件夹。