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

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

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

  • A class library is a strongly typed assembly that loads into the GAC.
  • Obviously the library is referenced in the project.
  • I added the <add namespace = "/> namespace to web.config
  • I rebuilt several times and restarted VS
  • Classlibrary has no problem ...

Any suggestions?

+5
source share
5 answers

Just create a view using any of the model classes, then manually edit the ASPX and replace the model class with the one you want. The dialog box is probably not intelligent enough.

But, in my personal opinion, using "external" classes as your models is very wrong.

All models, views and controllers should be here, right in your project. Then they can use internally everything they need, wherever they are.

+3
source

It's probably too late to answer this question, but for future readers:

, - > , - > , ( )

+7

, -...

, , "" , "DoorController" - . asp mvc.

"" ""? , .

+1

, - ( ). , , , MyRootNamespace.MyClassLibrary.MyNamespace.AnotherNamespace.TheClass ""?

0

, ... - ropstah 12 13:31

. " ", " " . , . , .

0

All Articles