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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:15:09+00:00 2026-05-30T06:15:09+00:00

I am trying to use my model in razor view and I am getting

  • 0

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.

My code in cshtml file is as follows:

@model VidLib.Models.LogedInUsersModel


@{
    ViewBag.Title = "LogedInUsers";
}

<h2>LoggedInUsers</h2>

@foreach (MembershipUser user in model.GetUsers())
{ 
   <p>Name: @user.UserName 
   </p>
}

My model code is as follows:

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();
        }

    }

}

The error I am getting is as follows:

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:  <h2>LoggedInUsers</h2>
Line 9:  
Line 10: @foreach (MembershipUser user in model.GetUsers())
Line 11: { 
Line 12:    <p>Name: @user.UserName 


Source File: d:\test projects\VidLib\VidLib\Views\Administrator\LogedInUsers.cshtml    Line: 10 



Show Detailed Compiler Output:


C:\WINDOWS\system32> "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:    // <auto-generated>
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:    // </auto-generated>
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<VidLib.Models.LogedInUsersModel> {
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<h2>LoggedInUsers</h2>\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("   <p>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   </p>\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 
  • 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-05-30T06:15:10+00:00Added an answer on May 30, 2026 at 6:15 am

    check the code in your view(LogedInUsers.cshtml) file.
    It’s Model ,not model

    @foreach (MembershipUser user in Model.GetUsers()) {

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

Sidebar

Related Questions

Im trying to use printf in my assembley code in model large, and i
I am trying to use the Model-View-Controller pattern in a small application. The model
I've been trying to use the default ASP.NET MVC model binders but I'm having
I'm trying to use an event dispatcher to allow a model to notify subscribed
I am trying to convert my spark views to use ViewData.Model instead of the
I have a Spring MVC application trying to use a rich domain model, with
Is it good to use an autoloader that load root/app/model/test.php when trying to use
I'm trying to get LinqPad use my dbml model so I could analyze a
I'm trying to use a WebGrid to display data in my model and am
I've inherited some code... and am trying to convert it to use MVC 3,

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.