0

In relation to my previous question, I want to set the returned List<Class1> listClass in my .cshtml file. However, I cannot create the following code in the .cshtml file since it does not recognize the Class1 class:

@ { 
    List<Class1> listClass = new List<Class1>();
}

<html>
    <!-- code for the view goes here -->
</html>

Class1 and the .cshtml file are located in different namespaces. Any help will be greatly appreciated.

Josh Monreal
  • 754
  • 1
  • 9
  • 29
  • What about add a using in your cshtml file: `@using MyNamespace`? – Claudio P Jun 01 '17 at 15:00
  • Possible duplicate of [How do I import a namespace in Razor View Page?](https://stackoverflow.com/questions/3239006/how-do-i-import-a-namespace-in-razor-view-page) – apocalypse Jun 01 '17 at 15:01

1 Answers1

1

Add the namespace your Class1 is located in, in a @using statement

How do I import a namespace in Razor View Page?

Reed
  • 1,515
  • 1
  • 21
  • 38