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 8562611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:46:01+00:00 2026-06-11T16:46:01+00:00

Im new to ASP.NET MVC3. I got stuck with this error, while I was

  • 0

Im new to ASP.NET MVC3. I got stuck with this error, while I was doing the same thing as here in these videos:

http://tv.telerik.com/watch/orm/building-a-mvc-3-application-database-first-with-openaccess-creating-model?seriesID=1529
and

http://tv.telerik.com/watch/orm/building-a-mvc-3-application-database-first-with-openaccess-creating-controllers

(i looked other similar questions on stack but didnt find the solution)

my code is:

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

namespace testbaza.Controllers
{
    public class KorController : Controller
    {

        private EntitiesModel dbContext;
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            if (this.Session[ContextModule.Content_KEY] != null)
            {
                this.dbContext = this.Session[ContextModule.Content_KEY] as EntitiesModel;
            }
            else {
                throw new Telerik.OpenAccess.Exceptions.NoSuchObjectException("Cannot find EntitiesModel", null);
            }
        }

and im getting this error: The name ‘ContextModule’ does not exist in the current context.

This is mine further code which i did before:

I added this in project\Web.config(same as in video 1):

 <httpModules>
      <add name="ContextModule" type="testbaza.ContextModule, testbaza"/>
    </httpModules>

I added ASP.NET module called “ContextModule” to \project(same as in video)

This is ContextModule.cs:

using System;
using System.Web;

namespace testbaza.Models
{
    public class ContextModule : IHttpModule
    {

        internal const string CONTEXT_KEY = "datacontext";

        public void Dispose()
        {

        }

        public void Init(HttpApplication context)
        {
            context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute);
            context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
        }

        private void context_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session != null)
            {
                HttpContext.Current.Session[CONTEXT_KEY] = new EntitiesModel();
            }
        }

        private void context_PostRequestHandlerExecute(object sender, EventArgs e)
        {
            CommitTransactions();

            DisposeContext();

            ClearSession();

        }

        private void CommitTransactions()
        {
            if (HttpContext.Current.Session == null)
            {
                return;
            }

            EntitiesModel dbContext =
                HttpContext.Current.Session[CONTEXT_KEY] as EntitiesModel;
            if (dbContext != null)
            {

                dbContext.SaveChanges();
            }
        }

        private void DisposeContext()
        {
            if (HttpContext.Current.Session == null)
            {
                return;
            }

            EntitiesModel dbContext =
                HttpContext.Current.Session[CONTEXT_KEY] as EntitiesModel;
            if (dbContext != null)
            {

                dbContext.Dispose();
            }
        }

        private void ClearSession()
        {

            if (HttpContext.Current.Session == null)
            {
                HttpContext.Current.Session.Remove(CONTEXT_KEY);
            }
        }
    }
}

Can anyone help me with the problem?
Thanks in advance!

  • 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-11T16:46:02+00:00Added an answer on June 11, 2026 at 4:46 pm

    In your controller add the following:

    using testbaza.Models;
    

    and you should be OK.

    Hope this helps

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

Sidebar

Related Questions

I'm working on ASP.NET MVC3 with C#. I got an error like below Type
I am building a new asp.net MVC3 web application for reporting and I want
i have a problem with the asp.net MVC3. when i create a new project
I am new in MVC3. When i create a new default ASP.NET MVC 3
New ASP.NET Web API HttpClient has been giving me some strange results. Here is
I am new to ASP.NET MVC3 and trying desperately to just get something simple
I am an ASP.NET WebForms programmer and I'm very new to ASP.NET MVC3. I've
New to ASP.NET MVC 3. This seems like it should be a really simple
I'm fairly new to asp.net MVC3. I followed the link below http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx it all
When creating a new asp.net mvc3 app you get the logon and register form

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.