title: MVC3 : Compiler Error Message: CS0103: The name 'model' does not exist in the current context
body: <p>I am trying to use my model in razor view and I am getting the above specified error. The default code (Account\ChangePassword.cshtml,...etc)generated in MVC3 containing @model keyword is working fine, only my new view is having the problem.</p>
  
  <p>My code in cshtml file is as follows:</p>
  
  <pre><code>@model VidLib.Models.LogedInUsersModel
  
  
  @{
      ViewBag.Title = "LogedInUsers";
  }
  
  &lt;h2&gt;LoggedInUsers&lt;/h2&gt;
  
  @foreach (MembershipUser user in model.GetUsers())
  { 
     &lt;p&gt;Name: @user.UserName 
     &lt;/p&gt;
  }
  </code></pre>
  
  <p>My model code is as follows:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Security;
  using System.ComponentModel.DataAnnotations;
  
  namespace VidLib.Models
  {
      public class LogedInUsersModel
      {
          public MembershipUserCollection GetUsers()
          {
              return Membership.GetAllUsers();
          }
  
      }
  
  }
  </code></pre>
  
  <p>The error I am getting is as follows:</p>
  
  <pre><code>Server Error in '/VTest' Application.
  --------------------------------------------------------------------------------
  
  Compilation Error 
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
  
  Compiler Error Message: CS0103: The name 'model' does not exist in the current context
  
  Source Error:
  
  
  
  Line 8:  &lt;h2&gt;LoggedInUsers&lt;/h2&gt;
  Line 9:  
  Line 10: @foreach (MembershipUser user in model.GetUsers())
  Line 11: { 
  Line 12:    &lt;p&gt;Name: @user.UserName 
  
  
  Source File: d:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml    Line: 10 
  
  
  
  Show Detailed Compiler Output:
  
  
  C:\WINDOWS\system32&gt; "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Routing\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Routing.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\assembly\dl3\81c380d9\4b4be05b_5ff0cc01\VidLib.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Helpers\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.Helpers.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\App_global.asax.4-dk6yw3.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\assembly\dl3\09b97a44\38235bb7_32e5cc01\EntityFramework.DLL" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Abstractions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Abstractions.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\App_Web_logedinusers.cshtml.e8fa2554.wfm-mxw5.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\App_Web_logedinusers.cshtml.e8fa2554.wfm-mxw5.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vtest\9fce5a68\47e852d4\App_Web_logedinusers.cshtml.e8fa2554.wfm-mxw5.1.cs"
  
  
  Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  d:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml(10,34): error CS0103: The name 'model' does not exist in the current context
  
  
  
  
  
  Show Complete Compilation Source:
  
  
  Line 1:    #pragma checksum "D:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "1D2E7C5249B30EC171BB04A575153072"
  Line 2:    //------------------------------------------------------------------------------
  Line 3:    // &lt;auto-generated&gt;
  Line 4:    //     This code was generated by a tool.
  Line 5:    //     Runtime Version:4.0.30319.1
  Line 6:    //
  Line 7:    //     Changes to this file may cause incorrect behavior and will be lost if
  Line 8:    //     the code is regenerated.
  Line 9:    // &lt;/auto-generated&gt;
  Line 10:   //------------------------------------------------------------------------------
  Line 11:   
  Line 12:   namespace ASP {
  Line 13:       using System;
  Line 14:       using System.Collections.Generic;
  Line 15:       using System.IO;
  Line 16:       using System.Linq;
  Line 17:       using System.Net;
  Line 18:       using System.Web;
  Line 19:       using System.Web.Helpers;
  Line 20:       using System.Web.Security;
  Line 21:       using System.Web.UI;
  Line 22:       using System.Web.WebPages;
  Line 23:       using System.Web.Mvc;
  Line 24:       using System.Web.Mvc.Ajax;
  Line 25:       using System.Web.Mvc.Html;
  Line 26:       using System.Web.Routing;
  Line 27:       
  Line 28:       
  Line 29:       public class _Page_Views_Administrator_LogedInUsers_cshtml : System.Web.Mvc.WebViewPage&lt;VidLib.Models.LogedInUsersModel&gt; {
  Line 30:           
  Line 31:   #line hidden
  Line 32:   
  Line 33:           
  Line 34:           public _Page_Views_Administrator_LogedInUsers_cshtml() {
  Line 35:           }
  Line 36:           
  Line 37:           protected ASP.global_asax ApplicationInstance {
  Line 38:               get {
  Line 39:                   return ((ASP.global_asax)(Context.ApplicationInstance));
  Line 40:               }
  Line 41:           }
  Line 42:           
  Line 43:           public override void Execute() {
  Line 44:   
  Line 45:   WriteLiteral("\r\n\r\n");
  Line 46:   
  Line 47:   
  Line 48:               
  Line 49:               #line 4 "D:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml"
  Line 50:     
  Line 51:       ViewBag.Title = "LogedInUsers";
  Line 52:   
  Line 53:   
  Line 54:               
  Line 55:               #line default
  Line 56:               #line hidden
  Line 57:   WriteLiteral("    \r\n&lt;h2&gt;LoggedInUsers&lt;/h2&gt;\r\n\r\n");
  Line 58:   
  Line 59:   
  Line 60:               
  Line 61:               #line 10 "D:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml"
  Line 62:    foreach (MembershipUser user in model.GetUsers())
  Line 63:   { 
  Line 64:   
  Line 65:               
  Line 66:               #line default
  Line 67:               #line hidden
  Line 68:   WriteLiteral("   &lt;p&gt;Name: ");
  Line 69:   
  Line 70:   
  Line 71:               
  Line 72:               #line 12 "D:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml"
  Line 73:          Write(user.UserName);
  Line 74:   
  Line 75:               
  Line 76:               #line default
  Line 77:               #line hidden
  Line 78:   WriteLiteral(" \r\n   &lt;/p&gt;\r\n");
  Line 79:   
  Line 80:   
  Line 81:               
  Line 82:               #line 14 "D:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml"
  Line 83:   }
  Line 84:   
  Line 85:               
  Line 86:               #line default
  Line 87:               #line hidden
  Line 88:   WriteLiteral("\r\n");
  Line 89:   
  Line 90:   
  Line 91:           }
  Line 92:       }
  Line 93:   }
  Line 94:   
  
  
  
  
  
  --------------------------------------------------------------------------------
  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 
  </code></pre>