asp.net mvc的 - 子文件夹 [英] asp.net mvc - subfolders

查看:222
本文介绍了asp.net mvc的 - 子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在新的微软asp.net MVC实现分区处理您的应用程序 - 例如:

How does the new Microsoft asp.net mvc implementation handle partitioning your application - for example:

--index.aspx
--about.aspx
--contact.aspx
--/feature1
--/feature1/subfeature/action
--/feature2/subfeature/action

我猜我想说的是,它似乎一切都已经进入意见/控制器的文件夹的根目录下的一个项目,如果以网络形式建立可能有很多很多的文件夹时可能得到笨拙和子文件夹进行分区应用程序。

I guess what I am trying to say is that it seems everything has to go into the root of the views/controllers folders which could get unwieldy when working on a project that if built with web forms might have lots and lots of folders and sub-folders to partition the application.

我觉得我得到的MVC模式,我喜欢它的外观相比,网络的形式,但仍然得到我的头一轮你将如何建立在实践一个大型项目。

I think I get the MVC model and I like the look of it compared to web forms but still getting my head round how you would build a large project in practice.

推荐答案

有没有您安排控制器的任何问题。你只需要设置路由采取组织考虑。你会遇到的问题是要找到控制器的看法,因为你改变了该公约。没有任何内置它的功能还没有,但它是很容易地创建自己周围工作与ActionFilterAttribute,并继承了ViewLocator自定义视图定位。然后创建你的控制器时,您只需指定什么ViewLocator使用,所以控制器知道如何找到的看法。如果需要,我可以张贴一些code。

There isn't any issues with organizing your controllers. You just need to setup the routes to take the organization into consideration. The problem you will run into is finding the view for the controller, since you changed the convention. There isn't any built in functionality for it yet, but it is easy to create a work around yourself with a ActionFilterAttribute and a custom view locator that inherits off ViewLocator. Then when creating your controller, you just specify what ViewLocator to use, so the controller knows how to find the view. I can post some code if needed.

这方法,一些建议我给其他人用于分离出自己的观点,使用ASP.NET MVC门户沿样去。这里是链接问题作为参考。

This method kind of goes along with some advice I gave another person for separating their views out for a portal using ASP.NET MVC. Here is the link to the question as a reference.

这篇关于asp.net mvc的 - 子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆