Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

ASP.net, MVC 4, C#, Razor -- SAME page, different user ?

What parameter passing (HTTP_Cookie, etc)
do I need during step #1 so the below #4 works ?

Steps
 1. worker is on order #5, clicks SWITCH_USER
 2. login box displays
 3. manager types their user/pass, clicks LOGIN
 4. same order #5 page displays
 5. manager clicks approve

I don't want to use cookies if I don't have to.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of finance_teacher
finance_teacher

ASKER

Can you provide a FULL example or webpage talking cookies with MVC  ?
Steps
 1. create new MVC 4 ASP.net APP, Template=Internet App
 2. change to below in "AccountController.cs"
 3. run APP
 4. login
 5. go to a different page
 6. click "LogOff"
 7. automatically get taken back to the page, just not logged in
 8. login
 9. same page displays
10. works

        public ActionResult LogOff()
        {

            HttpCookie MyCookie = new HttpCookie("lastURL");
            MyCookie.Value = Request.UrlReferrer.ToString();
            Response.Cookies.Add(MyCookie);

            WebSecurity.Logout();
            //return RedirectToAction("Index", "Home");
            return Redirect(MyCookie.Value);
        }

Below are some additional URLs if desired

http://stackoverflow.com/questions/6795575/reading-cookies-on-the-server-written-by-a-different-host-on-the-same-domain
http://stackoverflow.com/questions/9158225/using-cookie-in-asp-net-mvc-c-sharp
http://stackoverflow.com/questions/10629624/how-to-get-data-from-cookie-to-view-c-sharp-in-mvc3-using-viewbag
http://stackoverflow.com/questions/716636/how-do-i-access-request-cookies-in-controller-of-mvc-patternasp-net
http://stackoverflow.com/questions/5304782/how-to-get-current-page-url-in-mvc-3
http://stackoverflow.com/questions/5122404/how-do-you-clear-cookies-using-asp-net-mvc-3-and-c
http://stackoverflow.com/questions/15823965/mvc3-cookie-value-not-setting-in-viewdata-page
http://stackoverflow.com/questions/10790359/creating-and-accessing-cookies-in-asp-net-mvc3
Above #9 should take me to the page, but it does to HOME, changing AccountController.cs LOGIN is needed.