エリアが機能しない理由は何ですか?あなたが説明したことから、なぜ彼らがそうしないのか私にはよくわかりません。
- Areas
- Students
- Controllers
HomeController Handles base /Students/ route
InformationController ~/Students/Information/{action}/{id}
StatusController ~/Students/Status/{action}/{id}
...
- Models
- Views
Home/
Information/
Status/
...
Shared/ Stick common views in here
1つのモンスターコントローラー(またはパーシャル)を設定している場合、コントローラーには実際の「コードの表示」がほとんど含まれていないはずです。モデルを表示するためにすべてを任せます-コントローラーは、ビューデータを構築するために必要なリソースを渡すだけで、コントローラーを薄く保ちます。
つまり、
public class StudentController
{
...
// Actually I prefer to bind the id to a model and handle 404
// checking there, vs pushing that boiler plate code further down
// into the controller, but this is just a quick example.
public ActionResult Information(int id)
{
return View(new InformationPage(this.StudentService, id));
}
}
次に、InformationPage
そのビューに適用可能なすべての情報の構築を処理するモデルの1つです。
public class InformationPage
{
public Student Student { get; set; }
public InformationPage(StudentService service, int studentId)
{
Student = service.FindStudent(studentId);
... Other view data ...
}
}