Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i am just doing my first MVC 3 project with C#, but i have problem i have HomeController for notlogged in users and MembersControler for logged in user but evry time i debug even if i am logined i recive HomeControler but if i relog i recive MembersControler how i can solve this thath it will check evry time i debug if is already logged in it will show MembersControler.
Posted

1 solution

(assuming Forms Authentication)

Inside Home Controller:::
C#
public ActionResult Index() //or whatever your default action
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                RedirectToAction("MembersActionName", "MembersControllerName", null);  //replace the null with a viewModel as needed.
            }

            var viewModel = new IndexViewModel();
            return View(viewModel);
        }
 
Share this answer
 
Comments
HypoXxX 5-Jun-11 10:34am    
Hmmm dotn realy understand the latest view Model = new IndexView model

how will code looks like for exactly my code i have:

Map Controlers (AccountController, HomeController, MembersControler)

And in Views: Map Home (Index.cshtml))
Map Members (Main.cshtml)
Jpuckett 6-Jun-11 16:53pm    
Do you really want me to write your application for you? I charge by the hour for that.

If you can't figure out what passing a viewModel to a View does: maybe you should instead read up on MVC and pass me your client's project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900