Solved

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

Posted on 2013-05-17
4
658 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 82

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

627 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