0

I am using ASP.NET MVC with Areas and want to follow these procedure:

On load the application my first page will come login that is from main controller action result (Controller from main solutions explorer not Areas)

Suppose I have AccountController when I load the application my first page login post will call httppost of main controller actionmethod Login.

Here in Login controller I want to redirect to areas controller as per login done:

AccountController:

public ActionResult LoginEmployee(string Name, string Password)
        {
            if (Name == "Admin")
            {
                return RedirectToAction("Index", "AdminHome", new { Area = "Admin" });
            }
            else
            {
                return RedirectToAction("Index", "CustomerHome", new { Area = "Customer" });
            }
        }

But this code is not returning to Areas controller nothing happen may be I am doing anything wrong or something error.

Please tell me if anything wrong.

Thanks in advance.

3 rules
  • 1,359
  • 3
  • 26
  • 54
  • This might be a silly question, but have you confirmed that the URL that they are redirecting to are valid? (In other words, is there an /AdminHome /index). A common mistake would be making it go to ' /View/Index' instead of '/Index/View' – gavsta707 Jul 05 '17 at 18:43
  • @gavsta707 Ya might be silly sir for you because you may know this but I am new for this and yes I have areas name with AdminHome inside Areas and also CustomerHome as well with index actionresult inside each controller. – 3 rules Jul 05 '17 at 18:46
  • And i am assuming that both the AdminHome and CustomerHome are inside of your index folder. Because inside of a project, if i want to access a view that is in 'Views/Home' and is named 'MainView', i would want the URL to be 'Home/MainView'. So make sure you aren't getting it the other way around – gavsta707 Jul 05 '17 at 18:49
  • See: https://stackoverflow.com/questions/2140208/how-to-set-a-default-route-to-an-area-in-mvc – C. Helling Jul 05 '17 at 18:55
  • when you debug it and set breakpoints what does it say after each step? – Mindless Jul 06 '17 at 03:09
  • @Mindless nothing happens after it returns I mean redirects – 3 rules Jul 06 '17 at 05:51

0 Answers0