<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tag 'Controller'</title><link>http://forums.asp.net/search/SearchResults.aspx?q=&amp;tag=Controller&amp;orTags=0&amp;o=DateDescending</link><description>Search results matching tag 'Controller'</description><dc:language>en-US</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Navigating to a non-existing controller or view produces a blank page, is there a fix?</title><link>http://forums.asp.net/thread/3573687.aspx</link><pubDate>Fri, 18 Dec 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3573687</guid><dc:creator>MrKazoo</dc:creator><description>&lt;p&gt;I am developing a new ASP.NET MVC 1&amp;nbsp;application and keep running into this scenario.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my application I can trap calls to views that are not providing the proper ID setting, e.g. &lt;a href="http://www.site.com/existingcontroller/existingview"&gt;www.site.com/existingcontroller/existingview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The issue i am running into is when this same call is to a non-existing contoller or view, e.g. &lt;a href="http://www.site.com/nonexistingcontroller"&gt;www.site.com/nonexistingcontroller&lt;/a&gt; or &lt;a href="http://www.site.com/existingcontroller/nonexistingview"&gt;www.site.com/existingcontroller/nonexistingview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This seems to be a scenario that would be an issue for every ASP.NET MVC application but I can&amp;#39;t seem to find any help about it.&lt;/p&gt;
&lt;p&gt;Anyone out there solved this or know where the info to solve it is?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>upload image to database and retrieve using MVC and Entity</title><link>http://forums.asp.net/thread/3526012.aspx</link><pubDate>Sat, 21 Nov 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3526012</guid><dc:creator>openskymedia</dc:creator><description>&lt;p&gt;I&amp;#39;m trying to follow the instructions on this page: http://bit.ly/8hJfyr for storing and retreiving images from my database. I&amp;#39;m using mvc and the entity framework and i&amp;#39;m not having luck with adapting this code to work. i feel like either he&amp;#39;s assuming I should know stuff which I don&amp;#39;t or something is just missing.&lt;/p&gt;&lt;p&gt;Specifically this line: PhotoViewImage image = PhotoViewImage.GetById(id); is giving me errors. I know that I need to adapt this so that it&amp;#39;s retrieving my table.&lt;/p&gt;&lt;p&gt;In the comments it says that PhotoViewImage is a Entityframework class that has string name, string alternatetext, byte actual image and string content type.&lt;/p&gt;&lt;p&gt;Would that be going in the models folder or the controllers folder or am I on the wrong track all together?&lt;/p&gt;&lt;p&gt;Here is my ImageResultController.cs file: http://pastebin.com/m14eafd1f&lt;/p&gt;&lt;p&gt;Here is my ImagesController.cs file: http://pastebin.com/m45da9a92&lt;/p&gt;&lt;p&gt;and of course there&amp;#39;s my lonely PhotoViewImage.cs file: http://pastebin.com/m20566525&lt;/p&gt;</description></item><item><title>Route to a single controller action</title><link>http://forums.asp.net/thread/3436174.aspx</link><pubDate>Thu, 01 Oct 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3436174</guid><dc:creator>cranialsurge</dc:creator><description>&lt;p&gt;How do I create a rule for all URLs to a specific View folder to go to the same controller action ... ?&amp;nbsp;&lt;/p&gt;&lt;p&gt;For example any URL that ends in ~/Sections/ should go to ~/Sections/Index.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve tried the following to no avail:-&lt;/p&gt;&lt;p&gt;&lt;p&gt;&amp;nbsp;routes.MapRoute(&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;Sections&amp;quot;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Route name&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;Sections/*&amp;quot;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // URL with parameters&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new { controller = &amp;quot;Sections&amp;quot;, action = &amp;quot;Index&amp;quot;} &amp;nbsp;// Parameter defaults&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;);&lt;/p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;routes.MapRoute(&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;Sections&amp;quot;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Route name&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;Sections/*&amp;quot;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // URL with parameters&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new { controller = &amp;quot;Sections&amp;quot;, action = &amp;quot;Index&amp;quot;} &amp;nbsp;// Parameter defaults&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;);&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description></item><item><title>Suggestion for next version - expose controller name</title><link>http://forums.asp.net/thread/3432714.aspx</link><pubDate>Wed, 30 Sep 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3432714</guid><dc:creator>erick t</dc:creator><description>&lt;p&gt;It would be very useful to&amp;nbsp;have the name&amp;nbsp;of&amp;nbsp;the controller&amp;nbsp;exposed&amp;nbsp;on the object model, as I have often needed it. I can always get to it&amp;nbsp;via reflection on the type, but this is expensive, and doesn&amp;#39;t seem needed. To give the&amp;nbsp;current specific scenario I am working on, I have a basic tab control,&amp;nbsp;and it so happens that each tab maps to an action in a different controller. In the&amp;nbsp;display of the tab, I want to show&amp;nbsp;which is currently selected tab. The most common way I&amp;#39;ve seen this done is via cookies (jQuery, etc).&amp;nbsp;However, I have a model for the tabs, and one of the properties is IsSelected. I have an extension method that gets called&amp;nbsp;in the controller (BTW, another request would be an event on the controller on creation) that&amp;nbsp;populates the ViewData with the tabs. The catch is that I need to determine which one is selected, and if I know the controller name, I can figure that out. Make sense?&lt;/p&gt;
&lt;p&gt;In summary, I would love to see:&lt;/p&gt;
&lt;p&gt;An event or two that gets called when a controller is created&lt;/p&gt;
&lt;p&gt;A property that exposes the name of the controller, via convention.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br /&gt;Erick&lt;/p&gt;</description></item><item><title>How to add item to cache in controller's constructor?</title><link>http://forums.asp.net/thread/3350409.aspx</link><pubDate>Sun, 16 Aug 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3350409</guid><dc:creator>webster.net</dc:creator><description>&lt;p&gt;If I use HttpContext.Cache.Add&lt;/p&gt;&lt;p&gt;I get the error: &amp;quot;&lt;font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "&gt;System.NullReferenceException: Object reference not set to an instance of an object.&amp;quot; from the line in Default.aspx&lt;/font&gt;&lt;/p&gt;&lt;p&gt;httpHandler.ProcessRequest(HttpContext.Current);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Is there another way?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Passing collections as parameters from view to controller and via RedirectToAction</title><link>http://forums.asp.net/thread/3114270.aspx</link><pubDate>Thu, 23 Apr 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3114270</guid><dc:creator>SergID</dc:creator><description>
&lt;p&gt;I&amp;#39;m implementing the following scenario:&lt;/p&gt;

&lt;p&gt;There is view with a catalogue of items (like products) and a filter for them. Filter is a&amp;nbsp; list of checkboxes and each of the checkboxes represents one category for an item. The number of categories is not fixed.&lt;/p&gt;

&lt;p&gt;In my controller I get all the date for the filter with the following method: &lt;br /&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[AcceptVerbs(HttpVerbs.Post)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public RedirectToRouteResult List(int? page, &lt;span style="color:darkred;"&gt;FormCollection formCollection&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IEnumerable&amp;lt;int&amp;gt; categoryFilter = selectFilterIDs(formCollection, &amp;quot;category&amp;quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:teal;"&gt;//parsing the Form Collection object&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return RedirectToAction(&amp;quot;List&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; page = 1,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:darkred;"&gt;filterCategoryIDs = categoryFilter&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;this method passes all the data to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[AcceptVerbs(HttpVerbs.Get)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public ActionResult List(int? page,&lt;span style="color:darkred;"&gt; IEnumerable&amp;lt;int&amp;gt; filterCategoryIDs&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //restore selected and unselected values&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ViewData[&amp;quot;selectedCategories&amp;quot;] = filterCategoryIDs;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&amp;nbsp; .............

&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So after the redirect I get an empty IEnumerable&amp;lt;int&amp;gt; filterCategoryIDs. It is not equal to null, it is just empty. &lt;/p&gt;

&lt;p&gt;The same happens when I try to pass data from my view when making the pagination: &lt;/p&gt;

&lt;blockquote&gt;

&lt;p&gt;&amp;lt;%= Html.Pager(&lt;/p&gt;

&lt;p&gt;ViewData.Model.PageSize, &lt;/p&gt;

&lt;p&gt;ViewData.Model.PageNumber, &lt;/p&gt;

&lt;p&gt;ViewData.Model.TotalItemCount, &lt;/p&gt;

&lt;p style="color:darkred;"&gt;new { filterOrderTypeIDs = ViewData[&amp;quot;selectedOrderTypes&amp;quot;], filterCategoryIDs = ViewData[&amp;quot;selectedCategories&amp;quot;] })&lt;/p&gt;

&lt;p&gt;%&amp;gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;So the question is how to pass collections as parameters properly &lt;br /&gt;&lt;/p&gt;
</description></item><item><title>Why isn't UpdateModel virtual?</title><link>http://forums.asp.net/thread/2927035.aspx</link><pubDate>Mon, 09 Feb 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2927035</guid><dc:creator>simeyla</dc:creator><description>&lt;p&gt;I&amp;#39;ve heard Phil on a podcast say &amp;#39;traditionally people make things non-virtual unless theres a good reason not to, but we decided to make things virtual unless theres a good reason not to&amp;#39;...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Therefore you tell me why all the Controller.UpdateModel methods are non-virtual ? Is there a legitimate good reason?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I want to be able to do this :&lt;/p&gt;
&lt;p&gt;I have an abstract&amp;nbsp;base controller, and a model (ModelBase) used by all the models in my page. I want to be able to do UpdateModel (productsModel) and have it update the base model too.&lt;/p&gt;
&lt;p&gt;I just don&amp;#39;t want to use &amp;#39;new&amp;#39; as I am having to do.&lt;/p&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; abstract &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="1"&gt;&lt;font color="#2b91af" size="1"&gt;RRController&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; : &lt;/font&gt;&lt;font color="#2b91af" size="1"&gt;&lt;font color="#2b91af" size="1"&gt;Controller&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; RRController()&lt;br /&gt;: &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;base&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;() {&lt;br /&gt;}&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;protected&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;internal&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;&lt;u&gt;new&lt;/u&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; UpdateModel&amp;lt;TModel&amp;gt;(TModel model) &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; TModel : &lt;/font&gt;&lt;font color="#2b91af" size="1"&gt;&lt;font color="#2b91af" size="1"&gt;ModelBase&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;base&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;.UpdateModel(model);&lt;br /&gt;UpdateBaseModel(model);&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; UpdateBaseModel(&lt;/font&gt;&lt;font color="#2b91af" size="1"&gt;&lt;font color="#2b91af" size="1"&gt;ModelBase&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; model) &lt;br /&gt;{&lt;br /&gt;model.Initialized = &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;true&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;;&lt;br /&gt;model.PromotionID = ((&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;)Session[&lt;/font&gt;&lt;font color="#a31515" size="1"&gt;&lt;font color="#a31515" size="1"&gt;&amp;quot;PromotionId&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;] ?? &lt;/font&gt;&lt;font color="#a31515" size="1"&gt;&lt;font color="#a31515" size="1"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;).ToUpper();&lt;br /&gt;model.PartnerId = ((&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;?)Session[&lt;/font&gt;&lt;font color="#a31515" size="1"&gt;&lt;font color="#a31515" size="1"&gt;&amp;quot;PartnerId&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;]) ?? 6; &lt;/font&gt;&lt;font color="#008000" size="1"&gt;&lt;font color="#008000" size="1"&gt;// rolling razor #&amp;amp;#&amp;amp;#&amp;amp;#&amp;amp;#&amp;amp;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; 
&lt;p&gt;}&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: MVC Controller and URL logic?</title><link>http://forums.asp.net/thread/2838662.aspx</link><pubDate>Tue, 30 Dec 2008 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2838662</guid><dc:creator>ericis_com</dc:creator><description>&lt;p&gt;Holy crapoly! I thought MVC would make my life easier! :D&lt;/p&gt;

&lt;p&gt;Simpler answer: I overload my controller&amp;#39;s constructor to accept a URL and use the HttpContext&amp;#39;s HttpRequest URL in the default constructor?&lt;/p&gt;

&lt;p&gt;Better simpler answer: I create a custom &amp;quot;MyController&amp;quot; base class with the overloaded constructor to accept a URL and inherit this new base class in all of my controllers.&lt;/p&gt;

&lt;p&gt;Mildly complex answer: Evolve my custom MyController&amp;#39;s overloaded constructor to accept an &amp;quot;IApplicationContext&amp;quot; object whose actual implementation is injected by Unity and write custom implementations of &amp;quot;IApplicationContext&amp;quot; as needed that would likely mock HttpContext to some degree.&lt;/p&gt;

&lt;p&gt;Complex answer (IMHO): Mock the freaking HttpContext! Okay, it&amp;#39;s probably not THAT bad.&lt;/p&gt;</description></item><item><title>MVC + Unity Containers + MSTest?</title><link>http://forums.asp.net/thread/2838368.aspx</link><pubDate>Tue, 30 Dec 2008 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2838368</guid><dc:creator>ericis_com</dc:creator><description>How can I expose Unity to my MVC contollers for unit testing? I quickly found resources for exposing Unity to MVC through a Controller Factory in a custom HttpApplication Start event. But, unit tests usually create and call Controllers directly, so... I suppose I could create a custom Controller class that exposes and initializes Unity within a controller, but then I have the problem of running as a web application, maintaining a single instance of Unity to work with. I suppose I could attempt a static instance on some custom global object... Seems like such a kludge at this point.</description></item><item><title>How to redirect to another controller based on a wildcard</title><link>http://forums.asp.net/thread/2690391.aspx</link><pubDate>Fri, 17 Oct 2008 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2690391</guid><dc:creator>Dan Atkinson</dc:creator><description>&lt;p&gt;Hi there!
I have a problem which I&amp;#39;m sure should be fairly simple.&lt;/p&gt;
&lt;p&gt;I have several routes which catch various different types of urls that contain different structures, but they correspond to other urls which can be found inside the routescollection.&lt;/p&gt;&lt;pre class="coloredcode"&gt;routes.MapRoute(&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;products/{product}.htm&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="kwd"&gt;new&lt;/span&gt; { controller = &lt;span class="st"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;, action = &lt;span class="st"&gt;&amp;quot;ShowProduct&amp;quot;&lt;/span&gt; }&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;routes.MapRoute(&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;ProductReview&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;products/{product}/reviews.htm&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="kwd"&gt;new&lt;/span&gt; { controller = &lt;span class="st"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;, action = &lt;span class="st"&gt;&amp;quot;ShowProductReview&amp;quot;&lt;/span&gt; }&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;routes.MapRoute(&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;Partner&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="st"&gt;&amp;quot;partners/{partner}/{*wildcard}&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span class="kwd"&gt;new&lt;/span&gt; { controller = &lt;span class="st"&gt;&amp;quot;Partners&amp;quot;&lt;/span&gt;, action = &lt;span class="st"&gt;&amp;quot;PartnerRedirect&amp;quot;&lt;/span&gt; }&lt;br /&gt;);&lt;/pre&gt;
&lt;p&gt;In this example, I have the product route, and then I have partner sites which could also go to a product page.
For example, Lets say I go to http://mysite.com/products/cola.htm. This should go to the same url as http://mysite.com/partners/pesi/products/cola.htm, and the PartnerRedirect would be able to handle the url based on the wildcard.&lt;/p&gt;&lt;p&gt;My question is, how can I, from the wildcard, determine what controller to pass the user onto?&lt;/p&gt;&lt;p&gt;Many thanks in advance.&lt;/p&gt;</description></item></channel></rss>