<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Filter-ViewData anti-pattern</title>
	<atom:link href="http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Sun, 19 May 2013 03:22:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: mogadanez</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1616</link>
		<dc:creator>mogadanez</dc:creator>
		<pubDate>Fri, 17 Jul 2009 09:53:08 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1616</guid>
		<description>about performance:
i make simple test  shown that RenderAction and RenderPartial are very close by execution time.

http://mogadanez.blogspot.com/2009/07/aspnet-mvc-speed-test.html</description>
		<content:encoded><![CDATA[<p>about performance:<br />
i make simple test  shown that RenderAction and RenderPartial are very close by execution time.</p>
<p><a href="http://mogadanez.blogspot.com/2009/07/aspnet-mvc-speed-test.html" rel="nofollow">http://mogadanez.blogspot.com/2009/07/aspnet-mvc-speed-test.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: E</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1615</link>
		<dc:creator>E</dc:creator>
		<pubDate>Sun, 12 Jul 2009 18:36:03 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1615</guid>
		<description>@bogardj

Thank you.

I couldn&#039;t understand your first answer. For example, I have a Post.ascx and in which, I want to put &quot;Edit&quot; link if the Post&#039;s creator is the current user.
Where from should I bring the CurrentUser?

For the second answer - Thanks, makes sense.</description>
		<content:encoded><![CDATA[<p>@bogardj</p>
<p>Thank you.</p>
<p>I couldn&#8217;t understand your first answer. For example, I have a Post.ascx and in which, I want to put &#8220;Edit&#8221; link if the Post&#8217;s creator is the current user.<br />
Where from should I bring the CurrentUser?</p>
<p>For the second answer &#8211; Thanks, makes sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1614</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Sun, 12 Jul 2009 01:03:03 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1614</guid>
		<description>@E

First question - RenderPartial on all accounts.  If the data is completely orthogonal, RenderPartial.

Second question, for child partials, it&#039;s mapped on the parent to be the child type.

So,

OrderDto contains a list of OrderLineDto, and I have a partial for both OrderDto and OrderLineDto.  Make sense?</description>
		<content:encoded><![CDATA[<p>@E</p>
<p>First question &#8211; RenderPartial on all accounts.  If the data is completely orthogonal, RenderPartial.</p>
<p>Second question, for child partials, it&#8217;s mapped on the parent to be the child type.</p>
<p>So,</p>
<p>OrderDto contains a list of OrderLineDto, and I have a partial for both OrderDto and OrderLineDto.  Make sense?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: E</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1613</link>
		<dc:creator>E</dc:creator>
		<pubDate>Fri, 10 Jul 2009 18:23:10 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1613</guid>
		<description>And another question:

How do you pass another complex ViewData to a child partial?

Do you hold nested view data objects?

For example, a blog&#039;s post list page:

PostListViewData contains IEnumerable&lt;Post&gt; or IEnumerable&lt;PostViewData&gt; ?

The idea is to be able to have in Post.ascx more than a Post in some cases, and properties that aren&#039;t in the Post domain object.
If IEnumerable&lt;Post&gt; is used, then is it OK to instantiate PostViewData on the List.aspx?

For example:
&lt;%
foreach (Post p in Model.Posts) {
      Html.RenderPartial(&quot;Post&quot;,new PostViewData { Post=p,SomeOtherThing=someOtherThing });
}
%&gt;

Thanks!</description>
		<content:encoded><![CDATA[<p>And another question:</p>
<p>How do you pass another complex ViewData to a child partial?</p>
<p>Do you hold nested view data objects?</p>
<p>For example, a blog&#8217;s post list page:</p>
<p>PostListViewData contains IEnumerable
<post> or IEnumerable
<postviewdata> ?</p>
<p>The idea is to be able to have in Post.ascx more than a Post in some cases, and properties that aren&#8217;t in the Post domain object.<br />
If IEnumerable
<post> is used, then is it OK to instantiate PostViewData on the List.aspx?</p>
<p>For example:<br />
< %<br />
foreach (Post p in Model.Posts) {<br />
      Html.RenderPartial("Post",new PostViewData { Post=p,SomeOtherThing=someOtherThing });<br />
}<br />
%></p>
<p>Thanks!</post></postviewdata></post>
]]></content:encoded>
	</item>
	<item>
		<title>By: E</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1612</link>
		<dc:creator>E</dc:creator>
		<pubDate>Fri, 10 Jul 2009 17:46:08 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1612</guid>
		<description>Thank you for this article!

I have a question:

Where will you preserve &quot;global&quot; variables such as CurrentUser, UserScore, IsAdmin, CurrentTheme etc.?

Do you include it in every ViewData class that you need it in?
Or do you create a BaseViewData class and let all the ViewData classes inherit from? And if so, where do you fill these variables? In every action, action filter or on BaseController&#039;s OnActionExecuted?</description>
		<content:encoded><![CDATA[<p>Thank you for this article!</p>
<p>I have a question:</p>
<p>Where will you preserve &#8220;global&#8221; variables such as CurrentUser, UserScore, IsAdmin, CurrentTheme etc.?</p>
<p>Do you include it in every ViewData class that you need it in?<br />
Or do you create a BaseViewData class and let all the ViewData classes inherit from? And if so, where do you fill these variables? In every action, action filter or on BaseController&#8217;s OnActionExecuted?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sasan</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1611</link>
		<dc:creator>sasan</dc:creator>
		<pubDate>Wed, 08 Jul 2009 16:24:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1611</guid>
		<description>good</description>
		<content:encoded><![CDATA[<p>good</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1610</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 25 Jun 2009 00:51:17 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1610</guid>
		<description>@David

Since I&#039;m creating links based on controllers (strongly-typed Url.Action), for me it&#039;s no big stretch.  I understand those that are more route-centric it&#039;s a bit of a compromise.  At its base, RenderAction renders a route, and you&#039;re not forced to use the controller/action based version.

I imagine it as something like the chain of responsibility pattern - multiple controllers get a &quot;crack&quot; at a request, shaped by a view (since this is how we ultimately determine what HTML gets down to the client).</description>
		<content:encoded><![CDATA[<p>@David</p>
<p>Since I&#8217;m creating links based on controllers (strongly-typed Url.Action), for me it&#8217;s no big stretch.  I understand those that are more route-centric it&#8217;s a bit of a compromise.  At its base, RenderAction renders a route, and you&#8217;re not forced to use the controller/action based version.</p>
<p>I imagine it as something like the chain of responsibility pattern &#8211; multiple controllers get a &#8220;crack&#8221; at a request, shaped by a view (since this is how we ultimately determine what HTML gets down to the client).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Miles</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1609</link>
		<dc:creator>David Miles</dc:creator>
		<pubDate>Wed, 24 Jun 2009 21:24:58 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1609</guid>
		<description>RE: Pattern Violation

I&#039;m still with Mike &quot;Sampy&quot; Sampson on this, and not quite convinced by the IMG tag example. In the case of a browser making a request based on an IMG tag URL, it&#039;s still executing the routing logic on the server. By putting a direct reference to the LoginController in your view, you&#039;ve sort of &quot;hardcoded&quot; routing logic right in the view which doesn&#039;t quite &quot;feel&quot; right. I think it&#039;s closer than filtering, though.</description>
		<content:encoded><![CDATA[<p>RE: Pattern Violation</p>
<p>I&#8217;m still with Mike &#8220;Sampy&#8221; Sampson on this, and not quite convinced by the IMG tag example. In the case of a browser making a request based on an IMG tag URL, it&#8217;s still executing the routing logic on the server. By putting a direct reference to the LoginController in your view, you&#8217;ve sort of &#8220;hardcoded&#8221; routing logic right in the view which doesn&#8217;t quite &#8220;feel&#8221; right. I think it&#8217;s closer than filtering, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1608</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Tue, 23 Jun 2009 15:44:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1608</guid>
		<description>@moganez

Why can&#039;t you pass down the &quot;item&quot; down to RenderPartial?  We do this all the time, breaking our model into individual components rendered by strongly-typed views and partials.</description>
		<content:encoded><![CDATA[<p>@moganez</p>
<p>Why can&#8217;t you pass down the &#8220;item&#8221; down to RenderPartial?  We do this all the time, breaking our model into individual components rendered by strongly-typed views and partials.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moganez</title>
		<link>http://lostechies.com/jimmybogard/2009/06/19/the-filter-viewdata-anti-pattern/#comment-1607</link>
		<dc:creator>moganez</dc:creator>
		<pubDate>Tue, 23 Jun 2009 15:37:34 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/06/18/the-filter-viewdata-anti-pattern.aspx#comment-1607</guid>
		<description>@bogardi

i Have list with complex view.
with many and many variats.

very simlify

&lt;for each=&quot;var item in Model&quot;&gt;
  ${item.Name}
  &lt;rating if=&quot;item.CanRate&quot; /&gt;
  &lt;comment if=&quot;item.CanComment&quot; /&gt;
  &lt;manage if=&quot;item.CanManage&quot; /&gt;
&lt;/for&gt;

so if   i  use renderPartial, i need create a BIG, COMPLEX, viewdata.  and  it is not reusable with one item  view action






</description>
		<content:encoded><![CDATA[<p>@bogardi</p>
<p>i Have list with complex view.<br />
with many and many variats.</p>
<p>very simlify</p>
<p><for each="var item in Model"><br />
  ${item.Name}<br />
  <rating if="item.CanRate" /><br />
  <comment if="item.CanComment" /><br />
  <manage if="item.CanManage" /><br />
</for></p>
<p>so if   i  use renderPartial, i need create a BIG, COMPLEX, viewdata.  and  it is not reusable with one item  view action</p>
]]></content:encoded>
	</item>
</channel>
</rss>
