ISSUE IN MVC ROUTING

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
 864  View(s)
Ratings:
Rate this:

I have a page that I want it to have 2 different routes: "/Admin/Schedules" AND "/Schedules"

"/Admin/Schedules" if for admin users and the page will render some admin features and it needs to log in... on the other hand, "/Schedules" is for non-logged users and it will render non-admin features...

But, the page is the same and I specifically need these two routes.

  1. Alex Leblois

    Post:67

    Points:471
    Re: Issue in MVC routing

    you could accomplish this in the controller as ajma said by just having an if condition and a switch statement in a method that checks if the user exist like so:

    if(UserID !=null)

    {

     

       switch(UserPreference)

       {

           case 1:

                       action = "Schedules";

                       top = TypeOfPage.Admin;

                       view = "Schedules";

                       break;

            default:

                       action = "Schedules";

                       top = TypeOfPage.Nonuser;

                       view = "Schedules";

                       break;

        }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!