更改 MVC 2 项目的默认 Visual Studio 行为
我创建了一个带有嵌套区域的 MVC 2 项目,例如:
Areas
-->A
-->C
--> Controllers
--> Models
--> Views
-->D
--> Controllers
--> Models
--> Views
-->Controllers
-->Models
-->Views
-->B
-->E
--> Controllers
--> Models
--> Views
-->F
--> Controllers
--> Models
--> Views
-->Controllers
-->Models
-->Views
Controllers
Models
Views
只要我将区域注册文件中的区域名称修改为“A/C”而不是简单的“C”,该项目就可以正常工作并正确找到所有控制器/视图”。但是,Visual Studio 的默认行为对于该项目布局来说并不正确。如果我向“A/C/Controllers”内的控制器添加操作方法,右键单击并选择“添加视图”,VS 将创建文件夹和文件“A/Views/{controller}/{action}.aspx” “A/C/Views/{controller}/{action}”。
有没有办法改变这种默认行为?也许创建一个覆盖默认行为的附加组件?我对 .NET 和 VS 2010 还很陌生,因此非常感谢您的帮助。
I've created an MVC 2 project with nested areas, such as:
Areas
-->A
-->C
--> Controllers
--> Models
--> Views
-->D
--> Controllers
--> Models
--> Views
-->Controllers
-->Models
-->Views
-->B
-->E
--> Controllers
--> Models
--> Views
-->F
--> Controllers
--> Models
--> Views
-->Controllers
-->Models
-->Views
Controllers
Models
Views
This works and correctly finds all the controllers/views as long as I modify the area names in the area registration files to be "A/C" instead of simply "C". However, the default behavior for Visual Studio is not correct for this project layout. If I add an action method to a controller inside "A/C/Controllers", right-click and choose "Add View", VS creates the folder and file "A/Views/{controller}/{action}.aspx" instead of "A/C/Views/{controller}/{action}."
Is there a way to change this default behavior? Perhaps create an add-on that overrides the default behavior? I'm pretty new to .NET and VS 2010 so any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论