Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - How to create a strongly-typed view from classes in referenced class-library?

i'm trying to create a strongly-typed view using Visual Studio 2008. I can right-click a controller action and choose: Add view... In the next dialog window there is an option 'Create a strongly-typed view'. If I check this option I can select a list of classes that are in my current project.

However I cannot select the class I need which is in a class-library that I referenced.

  • The classlibrary is a strongly-typed assembly which is loaded in the GAC.
  • Obviously the library is referenced in the project.
  • I've added a <add namespace="namespace" /> in web.config
  • I've rebuilt multiple times, and restarted VS
  • Classlibrary doesn't have any problems...

Any suggestions?

like image 633
Ropstah Avatar asked May 12 '09 12:05

Ropstah


People also ask

What is strongly typed view in MVC view created with Model class?

Strongly typed views are used for rendering specific types of model objects, instead of using the general ViewData structure. By specifying the type of data, you get access to IntelliSense for the model class.

Which Razor syntax is used to strongly type a view to a model?

This is done using The @model directive, which is placed at the top of the view file specifying the type of the ViewModel that is being passed. When you use @model directive, the razor engine assigns that type to the Viewdata. Model property The Model property then returns the type declared.

What is strongly typed in MVC?

Strongly typed views are used for rendering specific types of model objects. By specifying type of data, visual studio provides intellisense for that class. View inherits from ViewPage whereas strongly typed view inherits from ViewPage where T is type of the model.


1 Answers

This is surely to late for answering this question,but for future readers:

i noticed that very often i have to build->clean solution and then to build->rebuild solution and the classes magically appear (as they should)

like image 102
Savvas Sopiadis Avatar answered Sep 28 '22 03:09

Savvas Sopiadis