<?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>ASP.NET MVC</title><link>http://forums.asp.net/1146.aspx</link><description>Discussions regarding Model-View-Controller (MVC) support in ASP.NET.  &lt;a href="http://forums.asp.net/1215.aspx"&gt;T4MVC subforum&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2241187.aspx</link><pubDate>Tue, 18 Mar 2008 21:47:16 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2241187</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2241187.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2241187</wfw:commentRss><description>&lt;br /&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public abstract class&lt;/span&gt; MyBase : Controller { &lt;span class="kwd"&gt;protected override void&lt;/span&gt; HandleUnknownAction(&lt;span class="kwd"&gt;string&lt;/span&gt; actionName) { &lt;span class="cmt"&gt;/* Do something here */&lt;/span&gt; } }&lt;br /&gt;&lt;br /&gt;&lt;span class="kwd"&gt;public class&lt;/span&gt; HomeController : MyBase { &lt;span class="cmt"&gt;/* regular controller actions go here */&lt;/span&gt; }&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2241101.aspx</link><pubDate>Tue, 18 Mar 2008 20:46:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2241101</guid><dc:creator>MeetNet</dc:creator><author>MeetNet</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2241101.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2241101</wfw:commentRss><description>&lt;p&gt;Can someone post definitive sample code (with a base Controller and one that inherits from it) showing how HandleUnknownaction should behave?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2220763.aspx</link><pubDate>Sat, 08 Mar 2008 19:07:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2220763</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2220763.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2220763</wfw:commentRss><description>&lt;p&gt;I just wanted to say, Scott (if you&amp;#39;re reading this).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;m used to doing my own research and I don&amp;#39;t instantly believe
everything i&amp;#39;m told. Something i was trying to get across to IMarshal,
but reading my comments again it sounded like i was taking a dig at you.&lt;/p&gt;&lt;p&gt;I apologise for that.&lt;/p&gt;&lt;p&gt;In fact, I hold you in the highest regard. As i&amp;#39;ve read your blog and listen to your podcast there&amp;#39;s no doubt that you are the awesomeness that your colleagues purport.&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2220140.aspx</link><pubDate>Sat, 08 Mar 2008 03:47:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2220140</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2220140.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2220140</wfw:commentRss><description>&lt;p&gt;Don&amp;#39;t believe everything you hear just because the person saying it should know better. Even the grues get it wrong sometimes.&lt;/p&gt;&lt;p&gt;Do you understand why HandleUnknownAction get&amp;#39;s called for every action, even if it&amp;#39;s a &amp;quot;known&amp;quot; action?&lt;/p&gt;&lt;p&gt;Hint: I&amp;#39;ve already told you.&lt;/p&gt;&lt;p&gt;Once you understand, you win.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2219989.aspx</link><pubDate>Fri, 07 Mar 2008 23:32:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2219989</guid><dc:creator>IMarshal</dc:creator><author>IMarshal</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2219989.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2219989</wfw:commentRss><description>&lt;p&gt;Thanks again for the feedback.&amp;nbsp; So I agree with creating a new Controller class (let&amp;#39;s call it AppController) derived from Controller and then define all of our application controller classes to in turn derive from AppController.&amp;nbsp; It is in AppController we can utilize the HandleUnknownAction handler to operate as I expect.&amp;nbsp; No problem with that.&amp;nbsp; However, I seem to be missing the point of his demo now using this InterceptionController.&amp;nbsp; Any thoughts?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2218464.aspx</link><pubDate>Fri, 07 Mar 2008 11:16:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2218464</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2218464.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2218464</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;tgmdbm:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Of course,&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You&amp;#39;re returning an InterceptionController which doesn&amp;#39;t have ANY actions. So ALL actions will be Unknown.&lt;/p&gt;&lt;p&gt;What you probably want to do is create a MyControllerBase class which overrides the HandleUnknownAction method. Then make all your controllers inherit from that and you&amp;#39;re good to go.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Watch the video again and don&amp;#39;t listen to what Scott is saying.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;(Can someone back me up on this please?)&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2217393.aspx</link><pubDate>Thu, 06 Mar 2008 21:23:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2217393</guid><dc:creator>IMarshal</dc:creator><author>IMarshal</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2217393.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2217393</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thanks for the reply.&amp;nbsp; If you watch the screencast I&amp;#39;m referring to you&amp;#39;ll see that Scott derives the HomeController from the standard Controller class as opposed to the InterceptionController.&amp;nbsp; Secondly, his code in the interception controller used a string comparison to throw an exception if you requested a specific action.&amp;nbsp; While it was for example/screencast purposes, that would defeat the intention of the HandleUnknownAction method - call me if the user requested an Action which doesn&amp;#39;t exist.&lt;/p&gt;&lt;p&gt;You can find the screencast &lt;a href="http://www.asp.net/learn/3.5-extensions-videos/video-270.aspx" title="MVC Release Candidate 2 Screencase #3"&gt;http://www.asp.net/learn/3.5-extensions-videos/video-270.aspx&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Any other thoughts?&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2216275.aspx</link><pubDate>Thu, 06 Mar 2008 13:01:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2216275</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2216275.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2216275</wfw:commentRss><description>&lt;p&gt;Of course,&lt;/p&gt;&lt;p&gt;You&amp;#39;re returning an InterceptionController which doesn&amp;#39;t have ANY actions. So ALL actions will be Unknown.&lt;/p&gt;&lt;p&gt;What you probably want to do is create a MyControllerBase class which overrides the HandleUnknownAction method. Then make all your controllers inherit from that and you&amp;#39;re good to go.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Issue in HandleUnknownAction method for custom Controller</title><link>http://forums.asp.net/thread/2215540.aspx</link><pubDate>Thu, 06 Mar 2008 06:19:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2215540</guid><dc:creator>IMarshal</dc:creator><author>IMarshal</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2215540.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2215540</wfw:commentRss><description>&lt;p&gt;I&amp;#39;ve just completed watching the Scott Hanselman screencasts of the new MVC release (congrads on the fast update!) and have encountered an issue with the HandleUnknownAction.&amp;nbsp; Here&amp;#39;s how you can reproduce the issue:&lt;/p&gt;&lt;p&gt;&amp;nbsp;1) Modify Global.asax.cs adding the following line&lt;/p&gt;&lt;p&gt;ControllerBuilder.Current.SetControllerFactory(typeof(Qubit.Controllers.InterceptingControllerFactory));&lt;/p&gt;&lt;p&gt;&amp;nbsp;2) Create a new file (I followed Scott&amp;#39;s example) titled &amp;#39;InterceptingControllerFactory.cs&amp;#39; in the Controllers folder&lt;br /&gt;&lt;/p&gt;&lt;p&gt;public class InterceptingControllerFactory : DefaultControllerFactory&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override IController GetControllerInstance(Type controllerType)&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; IController controller = base.GetControllerInstance(controllerType);&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; return new InterceptionController(controller);&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; }&lt;/p&gt;&lt;p&gt; 3) Create a new file (again following Scott&amp;#39;s example) titled &amp;#39;InterceptionController.cs&amp;#39; in the Controllers folder&lt;br /&gt;&amp;nbsp;public class InterceptionController : Controller&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private IController _controller;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public InterceptionController(IController interceptedController)&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; this._controller = interceptedController;&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; protected override void HandleUnknownAction(string actionName)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  // Shouldn&amp;#39;t this only execute for an unknown action?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  // It is executed for even the default url of http://localhost:49327/&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; //throw new InvalidOperationException(String.Format(&amp;quot;Sorry but we don&amp;#39;t allow &amp;#39;{0}&amp;#39; actions.&amp;quot;, actionName));&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;&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; this._controller.Execute(this.ControllerContext);&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; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;My expectation is for the HandleUnknownAction method to only execute on a Missing Action method when in fact it executes for URLs such as the default empty URL which is still handled by the routing engine.&amp;nbsp; Is my assumption incorrect or is this a bug?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks!&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>