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

  • Home
  • SEARCH
  • 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 9017037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:09:41+00:00 2026-06-16T04:09:41+00:00

First off, let’s start by saying I’m a rookie. That being said, I am

  • 0

First off, let’s start by saying I’m a rookie. That being said, I am building a web app in C# using MVC3 w/ EF4.3.1 using a db first approach. During the log on process, I want to set some session variables to be used throughout the app.

My issue is that I am not sure how to go about reading the values into the session variables. Below is the code currently in the AccountController.cs:

[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        if (Membership.ValidateUser(model.UserName, model.Password))
        {
            FormsAuthentication.SetAuthCookie(model.UserName, 
                                              model.RememberMe);
            if (Url.IsLocalUrl(returnUrl) 
                && returnUrl.Length > 1 
                && returnUrl.StartsWith("/")
                && !returnUrl.StartsWith("//") 
                && !returnUrl.StartsWith("/\\"))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
        else
        {
            ModelState.AddModelError("", 
                "The user name or password provided is incorrect.");
        }
    }

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

And from what I have read, I should be trying to use DbContext to access the property of a given field, similar to:

using (var context = new DbContext())
{
    var svc100 = context.SVC00100.Where(t => 
                        t.TECHEMAIL.Contains("model.UserName")

    // Read the current value of the Name property
    Session["Name"] = context.Entry(svc100).Property(u =>
                                                 u.Name).CurrentValue;
}

Now… How do I determine what should be used in place of DbContext() in the second code block? If I try to use the drop down and pick what I need, I do not see anything relating to my Entity (CPLUEntities) that contains the DbContext phrase.

Some of the links I’ve discovered:

Implement custom “ValidateUser” in MembershipProvider

Entity Framework Working with Property Values

Using DbContext in EF 4.1 Part 5: Working with Property Values

  • 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-16T04:09:42+00:00Added an answer on June 16, 2026 at 4:09 am
    using (var context = new DbContext())
      {
         var svc100 = context.SVC00100
                     .FirstOrDefault(t => t.TECHEMAIL.Contains(model.UserName));
    
         // Read the current value of the Name property
         if (svc100 != null && !String.IsNullOrEmpty(svc100.Name))
             Session["Name"] = svc100.Name;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me start off by saying that this is my first real Cocoa app.
First off, let me start by saying that I am totally new to working
Ok, let me first start off by saying that I've only ever dealt with
First off let me start by saying I am using CodeIgniter and the Facebook
First off, let me start by saying, I know this exact question has been
First off, let me preface this question by saying that my professor is firmly
First off, let me start off that I am not a .net developer. The
First off, let me clarify the platforms we are using. We have an ASP.NET
Let me first start off, sorry for the confusing title. I didn't know how
let me first off noting that I have absolutely no idea what I'm doing

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.