Given two assemblies:
project.web
project.lib
The project.web assembly references project.lib which contains some business logic. A simple class from project.lib:
public class Person
{
public string Name;
}
In project.web.Controllers:
Using project.lib.models;
public class PersonController : Controller
{
Person person = new Person();
public ActionResult Index()
{
return View(person);
}
}
This is the part where I have some questions. In a lot of sample projects I've seen the following in the View (in this case Index.aspx):
<% @Import Namespace="project.lib.models" %>
Allowing you to use the Model object like this:
<%= Model.Name %>
I haven't gotten that to work like the examples, I've had to do:
<%= (Model as Person).Name %>
or
<%
var person = (Person)Model;
Response.Write(person.Name);
%>
Why is this thus? What is the reason for this thusness? Comments? Suggestions? My class definition looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace project.lib.models
{
public class Person
{
public Int64 PersonID;
public string DisplayName;
public string RealName;
}
}