I've only read a few tidbits here and there about areas so far and haven't actually used them. Same for RenderAction, but I am running into a problem where I want to separate a certain piece of the page that is being used across all pages but has it's own functionality. With webforms I'd just be using a control. With MVC I was leaning towards the RenderAction method, and then bam today v2 preview 1 comes out with the "areas" support. RenderAction never really seemed all that support either being pushed out into the futures project.
到目前为止,我只在这里和那里读了一些关于领域的趣闻,还没有真正地使用它们。对于RenderAction来说也是一样,但是我遇到了一个问题,我想要把一个页面的某个部分分开,但是它有自己的功能。对于webforms,我只需要使用一个控件。使用MVC,我倾向于RenderAction方法,然后今天bam v2 preview 1提供了“区域”支持。RenderAction似乎从来都不是所有的支持都被推入期货项目。
My guess is that you'd want to now stay away from RenderAction as areas seems to have more future support. Right now though it seems that you'd need to create a entire new project just to have an "area"?
我的猜测是你现在想要远离渲染,因为区域似乎有更多的未来支持。现在,你似乎需要创建一个全新的项目来拥有一个“区域”?
So I'd have a SideBar project, a BreadCrumb project, a UserLoggedIn project...yikes.
所以我有一个侧边栏项目,一个面包屑项目,一个UserLoggedIn项目…
How the heck are people separating everything out? I can't be the only one that is running into this.
人们是怎么把所有东西分开的?我不可能是唯一遇到这种情况的人。
1 个解决方案
#1
2
Areas strikes me as a way to organize a large project into sectioned-off areas, whereas RenderAction has a specific purpose...providing a way to inject a "widget" into your page without having to push data into the view of every page that requires the widget, like you have to with a partial view.
在我看来,区域是将一个大型项目组织成分区的一种方式,而RenderAction有一个特定的目的……提供一种方法,将“小部件”注入到页面中,而不必向需要小部件的每个页面的视图中插入数据,就像您必须使用部分视图一样。
It's a perfect way to fill specific parts of a web page, such as a menu or sidebar...One line of code in the view calls a specific method on a specific controller and returns only the data you need for that particular part of the page.
这是填充网页特定部分的完美方法,比如菜单或侧边栏……视图中的一行代码调用特定控制器上的特定方法,只返回页面特定部分所需的数据。
This should alleviate your concerns about RenderAction being supported.
这将减轻您对RenderAction被支持的担忧。
FROM http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx
从http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx
re: ASP.NET MVC V2 Preview 1 Released
Friday, July 31, 2009 11:29 AM by ScottGu @Dominic,
2009年7月31日星期五上午11:29被ScottGu @Dominic,
Will Html.RenderAction() be making an appearance in ASP.NET MVC V2?
Html.RenderAction()将在ASP中出现。净MVC V2吗?
Yes - that is on the current plan for V2.
是的,这是V2的当前计划。
Thanks,
谢谢,
Scott
斯科特
#1
2
Areas strikes me as a way to organize a large project into sectioned-off areas, whereas RenderAction has a specific purpose...providing a way to inject a "widget" into your page without having to push data into the view of every page that requires the widget, like you have to with a partial view.
在我看来,区域是将一个大型项目组织成分区的一种方式,而RenderAction有一个特定的目的……提供一种方法,将“小部件”注入到页面中,而不必向需要小部件的每个页面的视图中插入数据,就像您必须使用部分视图一样。
It's a perfect way to fill specific parts of a web page, such as a menu or sidebar...One line of code in the view calls a specific method on a specific controller and returns only the data you need for that particular part of the page.
这是填充网页特定部分的完美方法,比如菜单或侧边栏……视图中的一行代码调用特定控制器上的特定方法,只返回页面特定部分所需的数据。
This should alleviate your concerns about RenderAction being supported.
这将减轻您对RenderAction被支持的担忧。
FROM http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx
从http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx
re: ASP.NET MVC V2 Preview 1 Released
Friday, July 31, 2009 11:29 AM by ScottGu @Dominic,
2009年7月31日星期五上午11:29被ScottGu @Dominic,
Will Html.RenderAction() be making an appearance in ASP.NET MVC V2?
Html.RenderAction()将在ASP中出现。净MVC V2吗?
Yes - that is on the current plan for V2.
是的,这是V2的当前计划。
Thanks,
谢谢,
Scott
斯科特