The name 'XXX' does not exist in the current context

Apr 1, 2009 at 12:22 AM
I'm walking through the tutorial, step-by-step.

When it tells me to create the "Details.aspx" view, I do so, and receive 25 errors, that the names 'Html' and 'Model' don't exist in the current context.

The first line of the created view looks like this:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" %>

If I take out the generic, and reference just System.Web.Mvc.ViewPage -- the errors go away.

Now... here's the lovely part -- If I load the source code from the codeplex site -- it functions without error.

I really want to walk through this -- I don't want to start with the finished project.  

Any ideas as to what could be causing this?

Thanks,
Simon



Coordinator
Apr 1, 2009 at 4:23 AM
This would make me wonder if the Project's namespace is NerdDinner or not. It would also make me wonder if ALL the classes have namespace NerdDinner around them.

2009/3/31 SimonPage <notifications@codeplex.com>

From: SimonPage

I'm walking through the tutorial, step-by-step.

When it tells me to create the "Details.aspx" view, I do so, and receive 25 errors, that the names 'Html' and 'Model' don't exist in the current context.

The first line of the created view looks like this:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" %>

If I take out the generic, and reference just System.Web.Mvc.ViewPage -- the errors go away.

Now... here's the lovely part -- If I load the source code from the codeplex site -- it functions without error.

I really want to walk through this -- I don't want to start with the finished project.  

Any ideas as to what could be causing this?

Thanks,
Simon



Read the full discussion online.

To add a post to this discussion, reply to this email (nerddinner@discussions.codeplex.com)

To start a new discussion for this project, email nerddinner@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Scott Hanselman
http://www.hanselman.com
Apr 1, 2009 at 4:20 PM
I checked the project properties: AssemblyName and Default Namespace are both "NerdDinner"

I've also gone through every cs file in my project, and they all begin (after the 'using' statements) with "namespace NerdDinner.XXX" (where XXX might be 'models, helpers, etc')

Any other thoughts?

Thanks,
Simon

Apr 1, 2009 at 4:28 PM
Also, too, remember that if I remove the "<NerdDinner.Models.Dinner>" generic from the page directive, the compiler is then able to find the Html and Model helpers (although the Model does not have the methods, obviously, of the type in the generic."

This has me stumped.  I tried it on a different machine and it worked fine.... but I -just- installed VS2008 and MVC 1.0 on this machine just before starting this project.

Thanks again,
Simon

Coordinator
Apr 2, 2009 at 5:39 PM
Can you diff the web.config from CodePlex with your own? I'm wondering if you're missing a compiler directive.  
Coordinator
Apr 2, 2009 at 5:42 PM
Do you still have a web.config in your View directory? There's the main web.config and then a tiny one in ~\Views.
Does NerdDinner.Models.Dinner realy exist? Open the DLL in Reflector and make sure the type is there.
Coordinator
Apr 2, 2009 at 5:44 PM
Are you running 2008 SP1?
May 13, 2009 at 9:38 AM

hello,me too,i have the same problem

no intellisense while writing "Model."

May 15, 2009 at 8:16 PM

I had a similar problem in a different MVC app that was started well before MVC 1.0 came out.  After much digging, I found the soultion here: http://stackoverflow.com/questions/615044/mvc-no-codebehind-strongly-typed-viewdata-headers-not-working

Essentially you are most likely missing a web.config in the root of your Views folder with this key bit of XML content:

    <pages

        validateRequest="false"

        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

      <controls>

        <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />

      </controls>

    </pages>