<?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: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2272186.aspx</link><pubDate>Wed, 02 Apr 2008 16:12:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2272186</guid><dc:creator>SteveSanderson</dc:creator><author>SteveSanderson</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2272186.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2272186</wfw:commentRss><description>&lt;p&gt;Or, if that&amp;#39;s what you want to do, you can replace it with a single line:&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:12pt;font-family:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;"&gt;FormsAuthentication.RedirectToLoginPage();&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2271551.aspx</link><pubDate>Wed, 02 Apr 2008 12:20:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2271551</guid><dc:creator>maartenba</dc:creator><author>maartenba</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2271551.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2271551</wfw:commentRss><description>&lt;p&gt;Another alternative to redirecting to login page:&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string redirectUrl = string.Format(&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; &amp;quot;{0}?returnUrl={1}&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FormsAuthentication.LoginUrl,&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; filterContext.HttpContext.Server.UrlEncode(filterContext.HttpContext.Request.Url.AbsolutePath)&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; filterContext.HttpContext.Response.Redirect(redirectUrl, true);&lt;/p&gt;
&lt;p&gt;Using this approach, you can specify the login url in your web.config &amp;lt;authentication&amp;gt;&amp;lt;forms&amp;gt; configuration.&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2270162.aspx</link><pubDate>Tue, 01 Apr 2008 23:04:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2270162</guid><dc:creator>ironside14</dc:creator><author>ironside14</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2270162.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2270162</wfw:commentRss><description>&lt;p&gt;Good workaround Steve!&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2262488.aspx</link><pubDate>Fri, 28 Mar 2008 16:51:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262488</guid><dc:creator>nberardi</dc:creator><author>nberardi</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262488.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262488</wfw:commentRss><description>&lt;p&gt;Hi guys, &lt;/p&gt;&lt;p&gt;I actually took the easy way out and just created an extension method.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;		&lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;
&lt;b id="2"&gt;2    &lt;/b&gt;		/// Redirects to action.
&lt;b id="3"&gt;3    &lt;/b&gt;		/// &amp;lt;/summary&amp;gt;
&lt;b id="4"&gt;4    &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;filterContext&amp;quot;&amp;gt;The filter context.&amp;lt;/param&amp;gt;
&lt;b id="5"&gt;5    &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;responseCode&amp;quot;&amp;gt;The response code.&amp;lt;/param&amp;gt;
&lt;b id="6"&gt;6    &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;actionName&amp;quot;&amp;gt;Name of the action.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;b id="7"&gt;7    &lt;/b&gt;		&lt;span class="kwd"&gt;public static void&lt;/span&gt; RedirectToAction(&lt;span class="kwd"&gt;this&lt;/span&gt; ControllerContext filterContext, &lt;span class="kwd"&gt;string&lt;/span&gt; actionName)
&lt;b id="8"&gt;8    &lt;/b&gt;		{
&lt;b id="9"&gt;9    &lt;/b&gt;			&lt;span class="kwd"&gt;if&lt;/span&gt; (String.IsNullOrEmpty(actionName))
&lt;b id="10"&gt;10   &lt;/b&gt;				&lt;span class="kwd"&gt;throw new&lt;/span&gt; ArgumentNullException(&lt;span class="st"&gt;&amp;quot;actionName&amp;quot;&lt;/span&gt;);
&lt;b id="11"&gt;11   &lt;/b&gt;
&lt;b id="12"&gt;12   &lt;/b&gt;			RouteValueDictionary values = &lt;span class="kwd"&gt;new&lt;/span&gt; RouteValueDictionary();
&lt;b id="13"&gt;13   &lt;/b&gt;			values.Add(&lt;span class="st"&gt;&amp;quot;action&amp;quot;&lt;/span&gt;, actionName);
&lt;b id="14"&gt;14   &lt;/b&gt;
&lt;b id="15"&gt;15   &lt;/b&gt;			RedirectToAction(filterContext, values);
&lt;b id="16"&gt;16   &lt;/b&gt;		}
&lt;b id="17"&gt;17   &lt;/b&gt;
&lt;b id="18"&gt;18   &lt;/b&gt;		&lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;
&lt;b id="19"&gt;19   &lt;/b&gt;		/// Redirects to action.
&lt;b id="20"&gt;20   &lt;/b&gt;		/// &amp;lt;/summary&amp;gt;
&lt;b id="21"&gt;21   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;filterContext&amp;quot;&amp;gt;The filter context.&amp;lt;/param&amp;gt;
&lt;b id="22"&gt;22   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;responseCode&amp;quot;&amp;gt;The response code.&amp;lt;/param&amp;gt;
&lt;b id="23"&gt;23   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;actionName&amp;quot;&amp;gt;Name of the action.&amp;lt;/param&amp;gt;
&lt;b id="24"&gt;24   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;controllerName&amp;quot;&amp;gt;Name of the controller.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;b id="25"&gt;25   &lt;/b&gt;		&lt;span class="kwd"&gt;public static void&lt;/span&gt; RedirectToAction(&lt;span class="kwd"&gt;this&lt;/span&gt; ControllerContext filterContext, &lt;span class="kwd"&gt;string&lt;/span&gt; actionName, &lt;span class="kwd"&gt;string&lt;/span&gt; controllerName)
&lt;b id="26"&gt;26   &lt;/b&gt;		{
&lt;b id="27"&gt;27   &lt;/b&gt;			&lt;span class="kwd"&gt;if&lt;/span&gt; (String.IsNullOrEmpty(actionName))
&lt;b id="28"&gt;28   &lt;/b&gt;				&lt;span class="kwd"&gt;throw new&lt;/span&gt; ArgumentNullException(&lt;span class="st"&gt;&amp;quot;actionName&amp;quot;&lt;/span&gt;);
&lt;b id="29"&gt;29   &lt;/b&gt;
&lt;b id="30"&gt;30   &lt;/b&gt;			&lt;span class="kwd"&gt;if&lt;/span&gt; (String.IsNullOrEmpty(controllerName))
&lt;b id="31"&gt;31   &lt;/b&gt;				&lt;span class="kwd"&gt;throw new&lt;/span&gt; ArgumentNullException(&lt;span class="st"&gt;&amp;quot;controllerName&amp;quot;&lt;/span&gt;);
&lt;b id="32"&gt;32   &lt;/b&gt;
&lt;b id="33"&gt;33   &lt;/b&gt;			RouteValueDictionary values = &lt;span class="kwd"&gt;new&lt;/span&gt; RouteValueDictionary();
&lt;b id="34"&gt;34   &lt;/b&gt;			values.Add(&lt;span class="st"&gt;&amp;quot;action&amp;quot;&lt;/span&gt;, actionName);
&lt;b id="35"&gt;35   &lt;/b&gt;			values.Add(&lt;span class="st"&gt;&amp;quot;controller&amp;quot;&lt;/span&gt;, controllerName);
&lt;b id="36"&gt;36   &lt;/b&gt;
&lt;b id="37"&gt;37   &lt;/b&gt;			RedirectToAction(filterContext, values);
&lt;b id="38"&gt;38   &lt;/b&gt;		}
&lt;b id="39"&gt;39   &lt;/b&gt;
&lt;b id="40"&gt;40   &lt;/b&gt;		&lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;
&lt;b id="41"&gt;41   &lt;/b&gt;		/// Redirects to action.
&lt;b id="42"&gt;42   &lt;/b&gt;		/// &amp;lt;/summary&amp;gt;
&lt;b id="43"&gt;43   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;filterContext&amp;quot;&amp;gt;The filter context.&amp;lt;/param&amp;gt;
&lt;b id="44"&gt;44   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;responseCode&amp;quot;&amp;gt;The response code.&amp;lt;/param&amp;gt;
&lt;b id="45"&gt;45   &lt;/b&gt;		/// &amp;lt;param name=&amp;quot;values&amp;quot;&amp;gt;The values.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;b id="46"&gt;46   &lt;/b&gt;		&lt;span class="kwd"&gt;public static void&lt;/span&gt; RedirectToAction(&lt;span class="kwd"&gt;this&lt;/span&gt; ControllerContext filterContext, RouteValueDictionary values)
&lt;b id="47"&gt;47   &lt;/b&gt;		{
&lt;b id="48"&gt;48   &lt;/b&gt;			VirtualPathData virtualPath = RouteTable.Routes.GetVirtualPath(filterContext, values);
&lt;b id="49"&gt;49   &lt;/b&gt;
&lt;b id="50"&gt;50   &lt;/b&gt;			&lt;span class="kwd"&gt;string&lt;/span&gt; url = &lt;span class="kwd"&gt;null&lt;/span&gt;;
&lt;b id="51"&gt;51   &lt;/b&gt;			&lt;span class="kwd"&gt;if&lt;/span&gt; (virtualPath != &lt;span class="kwd"&gt;null&lt;/span&gt;)
&lt;b id="52"&gt;52   &lt;/b&gt;				url = virtualPath.VirtualPath;
&lt;b id="53"&gt;53   &lt;/b&gt;
&lt;b id="54"&gt;54   &lt;/b&gt;			filterContext.HttpContext.Response.Redirect(url);
&lt;b id="55"&gt;55   &lt;/b&gt;		}
&lt;/pre&gt;&amp;nbsp;&amp;nbsp;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2262410.aspx</link><pubDate>Fri, 28 Mar 2008 16:17:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262410</guid><dc:creator>tumickey</dc:creator><author>tumickey</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262410.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262410</wfw:commentRss><description>&lt;p&gt;uhm ,that is great!&lt;/p&gt;&lt;p&gt;&amp;nbsp; Thanks .&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2262373.aspx</link><pubDate>Fri, 28 Mar 2008 16:01:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262373</guid><dc:creator>SteveSanderson</dc:creator><author>SteveSanderson</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262373.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262373</wfw:commentRss><description>&lt;p&gt;But what if your controller isn&amp;#39;t actually derived from System.Web.Mvc.Controller? This code will work either way:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public class&lt;/span&gt; MyFilterAttribute : ActionFilterAttribute
{
    &lt;span class="kwd"&gt;public override void&lt;/span&gt; OnActionExecuting(FilterExecutingContext filterContext)
    {
        RedirectToRoute(filterContext, 
            &lt;span class="kwd"&gt;new&lt;/span&gt; { controller = &lt;span class="st"&gt;&amp;quot;SomeController&amp;quot;&lt;/span&gt;, action = &lt;span class="st"&gt;&amp;quot;SomeAction&amp;quot;&lt;/span&gt; }
        );
    }

    &lt;span class="kwd"&gt;private void&lt;/span&gt; RedirectToRoute(FilterContext context, &lt;span class="kwd"&gt;object&lt;/span&gt; routeValues)
    {
        var rc = &lt;span class="kwd"&gt;new&lt;/span&gt; RequestContext(context.HttpContext, context.RouteData);
        &lt;span class="kwd"&gt;string&lt;/span&gt; url = RouteTable.Routes.GetVirtualPath(rc, 
            &lt;span class="kwd"&gt;new&lt;/span&gt; RouteValueDictionary(routeValues)).VirtualPath;
        context.HttpContext.Response.Redirect(url, &lt;span class="kwd"&gt;true&lt;/span&gt;);
    }
}&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2262353.aspx</link><pubDate>Fri, 28 Mar 2008 15:53:40 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262353</guid><dc:creator>tumickey</dc:creator><author>tumickey</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262353.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262353</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;public class LoginActionFilterAttribute : ActionFilterAttribute&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; public override void OnActionExecuting(FilterExecutingContext filterContext)&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; HttpSessionStateBase session = filterContext.HttpContext.Session;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; Controller control = filterContext.Controller as Controller;&lt;/b&gt;&lt;br /&gt;&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; &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; if (control != null)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (session[&amp;quot;Login&amp;quot;] == null)&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; filterContext.Cancel = true;&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;b&gt;control.HttpContext.Response.Redirect(&amp;quot;./Login&amp;quot;);&lt;/b&gt;&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;&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; }&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; base.OnActionExecuting(filterContext);&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;br /&gt;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261871.aspx</link><pubDate>Fri, 28 Mar 2008 12:52:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261871</guid><dc:creator>dimi3</dc:creator><author>dimi3</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261871.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261871</wfw:commentRss><description>&lt;p&gt;Thank you for your answers.&lt;br /&gt;For the moment, I will keep my also not ideal solution, which consist of this method (in the controller class itself):&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;[NonAction]
&lt;b id="2"&gt;2    &lt;/b&gt;&lt;span class="kwd"&gt;private void&lt;/span&gt; RedirectUserIfNotLoggedIn()
&lt;b id="3"&gt;3    &lt;/b&gt;{
&lt;b id="4"&gt;4    &lt;/b&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (!HttpContext.User.Identity.IsAuthenticated)
&lt;b id="5"&gt;5    &lt;/b&gt;    {
&lt;b id="6"&gt;6    &lt;/b&gt;        RedirectToAction(&lt;span class="st"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;);
&lt;b id="7"&gt;7    &lt;/b&gt;    }
&lt;b id="8"&gt;8    &lt;/b&gt;}
&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261839.aspx</link><pubDate>Fri, 28 Mar 2008 12:36:59 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261839</guid><dc:creator>jbardrof</dc:creator><author>jbardrof</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261839.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261839</wfw:commentRss><description>&lt;p&gt;Heh,&lt;/p&gt;&lt;p&gt;neither of which are really ideal, I&amp;#39;m still hoping they&amp;#39;ll make RedirectToAction and RenderView public in the next preview.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261835.aspx</link><pubDate>Fri, 28 Mar 2008 12:35:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261835</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261835.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261835</wfw:commentRss><description>&lt;p&gt;... or reflection ;)&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261829.aspx</link><pubDate>Fri, 28 Mar 2008 12:34:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261829</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261829.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261829</wfw:commentRss><description>&lt;p&gt;if( filterContext.Controller is MyController )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (filterContext.Controller as MyController).RedirectToAction(&amp;quot;Login&amp;quot;);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;public class MyController : Controller {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public new RedirectToAction(RouteValueDictionary values) { base.RedirectToAction( value ); } &lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now you just have to make all your controllers inherit from MyController.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It&amp;#39;s not ideal by any means. But it works. you could get the url from RouteTable.Routes.GetVirtualPath and call Response.Redirect yourself. but that&amp;#39;s a mess as well.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261826.aspx</link><pubDate>Fri, 28 Mar 2008 12:33:47 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261826</guid><dc:creator>jbardrof</dc:creator><author>jbardrof</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261826.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261826</wfw:commentRss><description>&lt;p&gt;Funny you should mention that!&lt;/p&gt;&lt;p&gt;&lt;a href="http://forums.asp.net/t/1234929.aspx" title="http://forums.asp.net/t/1234929.aspx"&gt;http://forums.asp.net/t/1234929.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;As was pointed out in this previous thread, this is exactly the kind of feedback the development team is looking for.&amp;nbsp; &lt;/p&gt;&lt;p&gt;In the meantime you could use reflection to &amp;quot;hack&amp;quot; your way into using the RedirectToAction.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>RedirectToAction in ActionFilterAttribute</title><link>http://forums.asp.net/thread/2261614.aspx</link><pubDate>Fri, 28 Mar 2008 11:04:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2261614</guid><dc:creator>dimi3</dc:creator><author>dimi3</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2261614.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2261614</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I want to create my own filter that redirects non-logged in users.&lt;br /&gt;Here is my class:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;&lt;span class="kwd"&gt;public class&lt;/span&gt; LoggedInUserOnly : ActionFilterAttribute&lt;br /&gt;&lt;b id="2"&gt;2    &lt;/b&gt;    {&lt;br /&gt;&lt;b id="3"&gt;3    &lt;/b&gt;        &lt;span class="kwd"&gt;public override void&lt;/span&gt; OnActionExecuting(FilterExecutingContext filterContext)&lt;br /&gt;&lt;b id="4"&gt;4    &lt;/b&gt;        {&lt;br /&gt;&lt;b id="5"&gt;5    &lt;/b&gt;            &lt;span class="kwd"&gt;base&lt;/span&gt;.OnActionExecuting(filterContext);&lt;br /&gt;&lt;b id="6"&gt;6    &lt;/b&gt;            &lt;span class="kwd"&gt;if&lt;/span&gt; (!filterContext.HttpContext.User.Identity.IsAuthenticated)&lt;br /&gt;&lt;b id="7"&gt;7    &lt;/b&gt;            {&lt;br /&gt;&lt;b id="8"&gt;8    &lt;/b&gt;                &lt;span class="cmt"&gt;//RedirectToAction(&amp;quot;Login&amp;quot;);&lt;/span&gt;
&lt;b id="9"&gt;9    &lt;/b&gt;            }&lt;br /&gt;&lt;b id="10"&gt;10   &lt;/b&gt;        }&lt;br /&gt;&lt;b id="11"&gt;11   &lt;/b&gt;    }&lt;br /&gt;&lt;/pre&gt;&amp;nbsp;How can I redirect non-logged in users?&lt;br /&gt;&amp;nbsp;</description></item></channel></rss>