asp.net mvc generic controller -


I am thinking of implementing a generic controller in ASP.NET MVC.

Platform Object Controller & lt; T & gt;

Where T is a (generated) platform object.

Is this possible? What are the experiences / documents?

For example, a related question is how the resulting URL

Yes It is, you can not use it directly, but you can get it and use the child

Here is the one I use:

  Public class croद्रer & lt; TNTTI, TINPT & gt; : Controller where TInput: new () where Tementi: new () {protected readable IRPO & lt; TENTity & gt; Repo; Private Readonly Eyebrider & lt; TNTTI, TINPT & gt; Builder; Public Crusher (IRPO & Lt; TNTTA; Repo, IBilder & lt; TNTTI, TINPT & gt; Builder) {this.repo = repo; This.builder = Builder; } Public Virtual Action Rational Index (Ant Page) {View Return (repo.get pageable (pages 1, 5)); } Create Public Functionality () {Return View (Builder.Bild Input (New Tentity)); } [HTTP post] Create public action result (TINput O) {If (ModelState. ISAIGID) see return (o); Repo.Insert (builder.BuilEntity (o)); Return Redirect Reactions ("Index"); }}  

and use:

  public class FieldController: Cruder & lt; Field, FieldInput & gt; {Public sector controller (IRPO & lt; field & gt; repo, iBilder & lt; field, field input & gt; builder): Base (repo, builder) {}} Public category measurement controller: Crowder & lt; Measure, measurement input & gt; {Public Volume Controller (IRPO & Lt; Margear & gt; Repo, IBilder & lt; Major, Major Input & gt; Builder): Base (Repo, Builder) {}} Public Category District Controller: Crowder & lt; District, District Input & gt; {District Controller (IRPO & Lt; District> Repo, IBilder & lt; District; District Input & gt; Builder): Base (Repo, Builder) {}} Public Sector Full Control: Croeder & Lt; Perfender, Perferrin Input & gt; {Public Filler Controller (IRPro & LeTinum; Parfator & gt; Repo, IBilder & lt; Perfeder, Perfarin input & gt; Builder): Base (repo, builder) {}}  

code Here is:

Update:

Now using this approach:


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -