---
title: "Model could not be found in MVC"  
description: "Model could not be found in MVC"  
author: "Anonymous User"  
published: 2013-02-04  
updated: 2013-02-04  
canonical: https://www.mindstick.com/forum/574/model-could-not-be-found-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# Model could not be found in MVC

Hi Everyone!

I have included a model and created a view file [as well as](https://www.mindstick.com/interview/2481/can-you-write-a-java-class-that-could-be-used-both-as-an-applet-as-well-as-an-application) a [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) to direct all of them

public class CreateNewUserModel\
{\
[Required]\
[Display(Name = "[User name](https://www.mindstick.com/interview/33836/how-to-check-current-user-name-of-database-in-sql-server)")]\
public string UserName { get; set; }

[Required(ErrorMessage = "Email required")]\
[EmailAddress(ErrorMessage = "Not a valid email")]\
public string UserEmail { get; set; }

[Required]\
[[StringLength](https://www.mindstick.com/forum/160244/how-to-use-stringlength-to-limit-the-length-of-a-string-property-in-a-model)(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]\
[DataType(DataType.Password)]\
[Display(Name = "Password")]\
public string Password { get; set; }

[DataType(DataType.Password)]\
[Display(Name = "[Confirm password](https://www.mindstick.com/blog/117/how-we-create-confirm-password-page-in-asp-dot-net)")]\
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]\
public string ConfirmPassword { get; set; }

[Required]\
[Display(Name = "Role")]\
public string UserRole { get; set; }\
public IEnumerable<System.Web.Mvc.SelectListItem> UserRoles { get; set; }\
}\
On top of the view file

I also have @model CreateNewUserModel

and here is the [compilation error](https://www.mindstick.com/forum/159699/what-is-a-compilation-error-in-dot-net-core-explain-with-an-example) I have got

Compilation Error \
Description: An error occurred during the compilation of a resource required to service this request. Please review the following [specific error](https://www.mindstick.com/forum/160112/how-to-create-custom-exceptions-in-dot-net-core-for-more-specific-error-handling-scenarios) details and modify

your [source code](https://www.mindstick.com/forum/33476/pls-send-me-source-code-for-changing-passward-in-asp-dot-net-i-tried-so-much-from-google-but-its-not-workining) appropriately.

Compiler [Error Message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration): CS0246: The type or namespace name 'CreateNewUserModel' could not be found (are you missing a using directive or an assembly reference?)

Source Error: \
Line 32: \
Line 33: \
Line 34: public class _Page_Views_Account_CreateNewUser_cshtml : System.Web.Mvc.WebViewPage<CreateNewUserModel> {\
Line 35: \
Line 36: #line hidden

Thanks in advance

## Replies

### Reply by AVADHESH PATEL

Hi Ankita Pandey!

You just need to either fully specify the name of the model type or import the namespace for the model.

In View page, required namespace and model name when you used model properties.

e.g.

@model <namespace>.<class name>

@model ProjectName.CreateNewUserModel

or

@using ProjectName\
@model CreateNewUserModel

Here "ProjectName" is an example that you replace it in which you defined your model class.

I hope it resolve your problem.


---

Original Source: https://www.mindstick.com/forum/574/model-could-not-be-found-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
