<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Passing Data to View Master Pages</title><link>http://asp.net</link><pubDate>Tue, 21 Jun 2011 09:54:52 GMT</pubDate><generator>umbraco</generator><description>Comments for Passing Data to View Master Pages</description><language>en</language><atom:link href="http://asp.net/rss/comments/27590" rel="self" type="application/rss+xml" /><item><title>Comment Posted by ratherhave</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Sat, 12 Jun 2010 20:05:26 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009074</guid><description><![CDATA[ <p>When does the DataContext get destroyed? I went to implement this and realized that the DataContext is left to be killed by garbage collection. Is this the right way to do this? I always use a &quot;using&quot; statement around all my statements to be deliberate about the destruction.</p><p></p><p>What about adding a destructor to the abstract class?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ratherhave.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by simonwilbert</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Thu, 05 Aug 2010 04:04:54 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009758</guid><description><![CDATA[ <p>Love the latter method, except the httpcontext application cache isn&#39;t available in the applicationcontroller constructor as it&#39;s set after the constructor completes.  How can I modify the later method so I can store the masterpage data in the application cache rather than viewdata?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/simonwilbert.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by dotnetdev09</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Thu, 19 Aug 2010 12:12:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009914</guid><description><![CDATA[ <p>@simonwilbert: You can use a static constructor.</p><p>public abstract class ApplicationController : Controller{ static ApplicationController() { } }</p><p>The static constructor will only get called when the application is started for the first time.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/dotnetdev09.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by archaeopterryx</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Sat, 04 Sep 2010 20:29:00 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000010124</guid><description><![CDATA[ <p>I love the idea of the ApplicationController - it is very powerful.  However, much like @simonwilbert, I ran into a problem where objects are not initialized at the ApplicationController constructor.  For me it is the Request and User objects.  (I want to check Request.IsAuthenticated and User.Identity.Name in order to provide user information to the View so that it can display user-specific content.)</p><p></p><p>Any way around this?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/archaeopterryx.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by boyank</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Fri, 15 Oct 2010 20:54:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000010634</guid><description><![CDATA[ <p>You can use the constructor or static constructor for the basics. However, if you want access to the context, just override the OnActionExecuting method:</p><p>protected override void OnActionExecuting(ActionExecutingContext filterContext)</p><p>{</p><p>    ApplicationSetting applicationSettings = null;</p><p>    var context = filterContext.RequestContext.HttpContext;</p><p></p><p>    // Optional: Work only for GET request</p><p>    if (context.Request.RequestType != &quot;GET&quot;)</p><p>        return;</p><p></p><p>    // Optional: Do not work with AjaxRequests</p><p>    if (context.Request.IsAjaxRequest())</p><p>        return;</p><p></p><p>    if (context.Application[&quot;applicationSettings&quot;] == null)</p><p>    {</p><p>        applicationSettings = _dataContext.loadApplicationSettings();</p><p>        context.Application[&quot;applicationSettings&quot;] = applicationSettings;</p><p>    }</p><p>    else</p><p>    {</p><p>        applicationSettings = (ApplicationSetting) context.Application[&quot;applicationSettings&quot;];</p><p>    }</p><p></p><p>    filterContext.Controller.ViewData[&quot;applicationSettings&quot;] = applicationSettings;</p><p>}</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/boyank.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by slabko</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Fri, 29 Oct 2010 13:25:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000010764</guid><description><![CDATA[ <p>How can I run unit test for solution with OnActionExecuting?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/slabko.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jlathigee</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Tue, 21 Dec 2010 14:08:56 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011263</guid><description><![CDATA[ <p>Please include versions and dates in your articles / tutorials / etc. Is this still the best way to accomplish this? Don&#39;t know because don&#39;t know how old this is...</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/jlathigee.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ziaur10</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Tue, 08 Mar 2011 02:33:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012386</guid><description><![CDATA[ <p>nice! I have liked it.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ziaur10.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jsanta</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Tue, 24 May 2011 13:06:54 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013263</guid><description><![CDATA[ <p>Very easy to understand, thanks!</p><p></p><p>One question: How can I pass parameters to ApplicationController() constructor?(parameters sended from the final user).</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/jsanta.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jsanta</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Tue, 24 May 2011 13:10:30 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013264</guid><description><![CDATA[ <p>I know I can do it with base( ) in the other controller&#39;s constructor, but if I need to pass parameters sended from the final user the only thing that comes to my mind are Session[] values.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/jsanta.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by cherven</title><link>http://asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs</link><pubDate>Tue, 21 Jun 2011 09:54:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013575</guid><description><![CDATA[ <p>it is 101 solution :(</p><p></p><p>but we don&#39;t have better :(</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/cherven.jpg?forceidenticon=false&amp;dt=635045918400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>