Solved

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

Posted on 2013-05-17
4
654 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 81

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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