简体   繁体   English

如何确定要返回哪个视图

[英]How to determine which view is being returned

I have a controller ( AccountController.cs ) whose final statement of its Index method is return View(model); 我有一个控制器( AccountController.cs ),其Index方法的最终声明为return View(model); .

In global.asax the only route I can see which relates to this is: 在global.asax中,我只能看到与此相关的路由:

routes.MapRoute("AccountIndex", "Account/Index", new {controller = "Account", action = "Index"});

There is a Views folder, but it appears to only contain partial views and a master. 有一个“视图”文件夹,但它似乎只包含部分视图和一个主视图。 When I right-click and select "Go To View" I get a "Cannot find view" message, although it seems to do this on all of the controller methods. 右键单击并选择“转到视图”时,尽管似乎在所有控制器方法上都执行此操作,但会收到“找不到视图”消息。

So where can I find this view? 那么我在哪里可以找到此视图? Where is it located? 它在哪里? Any pointers? 有指针吗?

除非modelstring ,否则它可能会映射到Index局部视图。

when you don't have view for controller action (for example: Index) you can click right mouse button on "return View();" 当您没有控制器操作的视图(例如:索引)时,可以在“ return View();”上单击鼠标右键。 in controller method to automatically generate view. 在控制器方法中自动生成视图。 by default if you have controller with name "AccountController" and action "Index" the view should be in View\\Account\\Index.cshtml [if you use razor]. 默认情况下,如果控制器的名称为“ AccountController”,且操作为“ Index”,则视图应位于View \\ Account \\ Index.cshtml中(如果使用剃刀)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM