Solved

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

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

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