Solved

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

Posted on 2013-05-17
4
641 Views
Last Modified: 2013-05-20
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.
0
Comment
Question by:finance_teacher
  • 3
4 Comments
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 39176461
you need to use cookies because http is stateless.. so you need a way of passing the session token from page to page.
0
 

Author Comment

by:finance_teacher
ID: 39180877
Can you provide a FULL example or webpage talking cookies with MVC  ?
0
 

Author Comment

by:finance_teacher
ID: 39181971
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
0
 

Author Comment

by:finance_teacher
ID: 39182016
Above #9 should take me to the page, but it does to HOME, changing AccountController.cs LOGIN is needed.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now