我应该在ASP.NET MVC中使用区域还是RenderAction? [英] Should I use Areas or RenderAction in ASP.NET MVC?

查看:335
本文介绍了我应该在ASP.NET MVC中使用区域还是RenderAction?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里只读了一些关于迄今为止的区域,并没有实际使用它们。对于RenderAction而言,它是一样的,但是我遇到一个问题,我想分离所有页面中正在使用的页面的某个部分,但是它具有自己的功能。使用webforms我只是使用一个控件。使用MVC我倾向于RenderAction方法,然后bam今天v2预览1出来与区域支持。 RenderAction从来没有真的像所有的支持被推出到期货项目。

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,因为区域似乎有更多的未来支持。现在,虽然似乎你需要创建一个全新的项目,只是为了拥有一个区域?

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"?

所以我会有一个SideBar项目,一个BreadCrumb项目,一个UserLoggedIn项目... yikes。

So I'd have a SideBar project, a BreadCrumb project, a UserLoggedIn project...yikes.

如何将人们分离出来?我不能成为唯一一个遇到这种情况的人。

How the heck are people separating everything out? I can't be the only one that is running into this.

推荐答案

区域打击我是组织大型项目的一种方式进入分区,而RenderAction有一个特定的目的...提供了一种将widget注入到页面中的方式,而无需将数据推送到需要窗口小部件的每个页面的视图中,就像您必须使用部分视图。

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.

这是填充网页的特定部分(如菜单或侧边栏)的完美方式...视图中的一行代码调用了一个特定的方法在特定控制器上,只返回页面特定部分所需的数据。

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.

这应该可以减轻您的疑虑关于RenderAction被支持。

This should alleviate your concerns about RenderAction being supported.

FROM http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1 -released.asp x

2009 11:29 AM由ScottGu
@Dominic,

Friday, July 31, 2009 11:29 AM by ScottGu @Dominic,


将Html.RenderAction()在ASP.NET中出现MVC V2?

Will Html.RenderAction() be making an appearance in ASP.NET MVC V2?

是 - 这是V2的当前计划。

Yes - that is on the current plan for V2.

谢谢,

Scott

这篇关于我应该在ASP.NET MVC中使用区域还是RenderAction?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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