Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:05:16+00:00 2026-06-13T20:05:16+00:00

I have an MVC 3 application, it use asp validation when the user logs

  • 0

I have an MVC 3 application, it use asp validation
when the user logs in the app the validadion succeed and sotore user name in a session variable.

At here everithing works fine.

then in the AccountController i Set a RedirectionToAction, to another controller, here the session variables are lost.

**//HERE THE VARIABLES ARE LOST AND AN ERROR HAPPENS**
return RedirectToAction("menuOtbr", "Menu", new { area = "Configuracion" });

I’ve tryed

  1. Change from InProc to ServerState and problem persists,
  2. Deactivate my AV.
  3. Adding protected void Session_Start(){} nothing happens. the session doesn’t start or restart again.

  4. Other many suggestions almost all articles published with this related topic was readed an applyed by me.

here is my code:

        [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            //  Se inicializa variables para el gestor de mensajes 
            SessionBag.Current.ErrorMessageAuto = new ArrayList();
            SessionBag.Current.ErrorMessage = null;
            SessionBag.Current.ErrorReturnTo = null;

            //Se verifica si el usuario es válido en el contexto de SQL Server, esto para guardar 
             //compatibilidad con el diseño de Merlin para Escritorio.
            Db_Conexion db = new Db_Conexion(model.UserName,model.Password);
            if (!db.connect())
            {
                model.UserName = null;
                model.Password = null;
                SessionBag.Current.ErrorReturnTo = "link";
                SessionBag.Current.ErrorMessage = db.ExceptionsText();
                return View("Mensajes");
            }
            db.close();

            if (Membership.ValidateUser(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                SessionBag.Current.UserName = model.UserName;

                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    **//HERE THE VARIABLES ARE LOST AND AN ERROR HAPPENS**
                    return RedirectToAction("menuOtbr", "Menu", new { area = "Configuracion" });
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

I have the account controller at root’s project and another controllers structured by areas.

Project Structure

Almost 10 days spent trying to solve this. Any Ideas, help would be very apreciated.

The same error happens boot at deployment or production.

This article Losing my session variables – What exception might cause sessions to be lost?

say about some IIS configuration. But doesn’t explain exactly what things need to be configured.

SessionBags Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Dynamic;

namespace ParadigmaNet.Infraestructure
{
public sealed class SessionBag : DynamicObject
{
    private static readonly SessionBag sessionBag;

    static SessionBag()
    {
        sessionBag = new SessionBag();
    }

    private SessionBag()
    {
    }

    private HttpSessionStateBase Session
    {
        get { return new HttpSessionStateWrapper(HttpContext.Current.Session); }
    }

    public override bool TryGetMember(GetMemberBinder binder, out object result)
    {
        result = Session[binder.Name];
        return true;
    }

    public override bool TrySetMember(SetMemberBinder binder, object value)
    {
        Session[binder.Name] = value;
        return true;
    }

    public override bool TryGetIndex(GetIndexBinder
           binder, object[] indexes, out object result)
    {
        int index = (int)indexes[0];
        result = Session[index];
        return result != null;
    }

    public override bool TrySetIndex(SetIndexBinder binder,
           object[] indexes, object value)
    {
        int index = (int)indexes[0];
        Session[index] = value;
        return true;
    }

    public static dynamic Current
    {
        get { return sessionBag; }
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:05:18+00:00Added an answer on June 13, 2026 at 8:05 pm

    After days and hours of tests, Found some problems on web.config.

    Recently we change our app from MVC3 to MVC4, and find some diferences between web.config on boot strucutres, we made some changes, drop some keys and add others.

    After that everything is working ok.

    We generate a clean MVC4 app then compare web.config with the old web.config and procceed to remove some keys and modify anothers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am about to use linqtosql in my first asp.net mvc application. I have
I have a COM library I should use in my ASP.NET MVC application. However
We have a ASP.NET MVC 3 application that uses unobtrusive jQuery validation. The page
I am looking to use CKEditor in ASP MVC application. I have been having
I have a ASP.NET MVC 2.0 application using Entity Framework. All my views use
I have a form in my ASP.NET MVC 3 application that will use jquery
I have an ASP MVC application which I also use (as a requirement) as
I have MVC application configured to use Forms Authentication. I'm signing out users by
I have an mvc application that has been coded to use Windows authentication and
I have a Spring MVC application trying to use a rich domain model, with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.