Advanced Search

Results 1 to 6 of 6

Thread: MVC login reset help...

  1. #1
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Smile MVC login reset help...

    Hi guys,

    I made an mvc3 login page and when I login I press the back button on my browser which brings me back to the login page, but when i press forward again it logs me in again, i want to prevent it from keeping me logged in. I hope you got that


    Autoservice.
    Last edited by Autoservice; 04-03-2012 at 01:10 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    when your login page receives a login attempt, it needs to check if the user is already logged in before doing anything else.

    ...If I understood you problem correctly. If not,
    Your question is unclear.
    Please provide more information, and be as specific as possible.
    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Also, please be sure that you have included all relevant code and/or a link to the page in question.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  3. The Following User Says Thank You to traq For This Useful Post:

    Autoservice (04-04-2012)

  4. #3
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    "when your login page receives a login attempt, it needs to check if the user is already logged in before doing anything else." Yes this is what i want to accomplish, sorry for the bad explanation to my question, I was very tired last night ^^ .

  5. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I've never seen your code, so I don't have any more specific advice

    ( hint, hint ... )
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  6. The Following User Says Thank You to traq For This Useful Post:

    Autoservice (04-04-2012)

  7. #5
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    I've never seen your code, so I don't have any more specific advice

    ( hint, hint ... )
    Sorry, i have much work to do (projects)

    So the code is below

    Code:
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using CarReviews.Models;
    
    namespace CarReviews.Controllers
        
    {
        [Authorize]
        public class CarController : Controller
        {
            private RidesEntities db = new RidesEntities();
    
            //
            // GET: /Default1/
            [Authorize(Roles = "Admin")]
            public ViewResult Index()
            {
                var cars = db.Cars.Include(c => c.Pricing);
                return View(cars.ToList());
            }
    
            //
            // GET: /Default1/Details/5
    
            public ViewResult Details(int id)
            {
                Car car = db.Cars.Find(id);
                return View(car);
            }
    
            //
            // GET: /Default1/Create
           // [Authorize(Users="Bob")]
            [Authorize(Roles = "admin")]
            [Authorize(Roles = "user")]
    
            public ActionResult Create()
            {
                ViewBag.price_id = new SelectList(db.Pricings, "price_id", "insurance_group");
                return View();
            } 
    
            //
            // POST: /Default1/Create
    
            [HttpPost]
            public ActionResult Create(Car car)
            {
                if (ModelState.IsValid)
                {
                    db.Cars.Add(car);
                    db.SaveChanges();
                    return RedirectToAction("Index");  
                }
    
                ViewBag.price_id = new SelectList(db.Pricings, "price_id", "insurance_group", car.price_id);
                return View(car);
            }
            
            //
            // GET: /Default1/Edit/5
     
            public ActionResult Edit(int id)
            {
                Car car = db.Cars.Find(id);
                ViewBag.price_id = new SelectList(db.Pricings, "price_id", "insurance_group", car.price_id);
                return View(car);
            }
    
            //
            // POST: /Default1/Edit/5
    
            [HttpPost]
            public ActionResult Edit(Car car)
            {
                if (ModelState.IsValid)
                {
                    db.Entry(car).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                ViewBag.price_id = new SelectList(db.Pricings, "price_id", "insurance_group", car.price_id);
                return View(car);
            }
    
            //
            // GET: /Default1/Delete/5
     
            public ActionResult Delete(int id)
            {
                Car car = db.Cars.Find(id);
                return View(car);
            }
    
            //
            // POST: /Default1/Delete/5
    
            [HttpPost, ActionName("Delete")]
            public ActionResult DeleteConfirmed(int id)
            {            
                Car car = db.Cars.Find(id);
                db.Cars.Remove(car);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
    
            protected override void Dispose(bool disposing)
            {
                db.Dispose();
                base.Dispose(disposing);
            }
        }
    }
    Last edited by jscheuer1; 04-04-2012 at 01:36 AM. Reason: Format

  8. #6
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    Kill all the sessions on the login page before the login script.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •