views:

18

answers:

1

Hello,

i have a Log on in APS MVC 2.0 and if not logged on, i want to redirect the user to that page.

i found the way to do it is usin the RedirectAction (found several times on google, even on stack Overflow)

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: ViewData["Message"] %></h2>
    <p>
        <% if (Request.IsAuthenticated) { %>
            Go to this page <%:  Html.ActionLink("Manage Payment Run", "ManagePaymentRun")%>
        <%} else { %>
          <%  return RedirectToAction("LogOn", "Account"); %>
        <% } %>
    </p>
</asp:Content>

Now, the problem is that i get "The name RedirectToAction does not exist in the current context". I was wondering if anyone here knows why this happens, since my googling skill didnt even get close to finding anyone with a similar problem.

Thanks for your time.

+1  A: 

Unless I'm wrong, RedirectToAction is method used within a controller. It's part of the Controller class and thus cannot be used from a view.

I think you may need to read through this blog post for more info in helping you.

Ahmad
Thank you, i am still new to MVC, and i need to get used to the controllers.
Andy