Ram.AdminFramework
1.0.0
Kerangka Administrasi untuk ASP.NET MVC
Ide dasar perpustakaan ini adalah Dasbor Administrasi Kelahiran tanpa area bernama seperti ## Admin
Contoh 1: Homecontroller Dasar di Area Home
public class HomeController : Controller {
public ActionResult Index ( ) {
return Content ( "this is home page... " ) ;
}
public ActionResult About ( ) {
return Content ( "this is about page... " ) ;
}
public ActionResult Contacts ( ) {
return Content ( "this is contacts page... " ) ;
}
}Dan kelas arearegistrasi
public class HomeAreaRegistration : AreaRegistration {
public override void RegisterArea ( AreaRegistrationContext context ) {
context . Routes . MapRoute ( "index" , "" , new {
controller = "Home" ,
action = "index"
} ) ;
context . Routes . MapRoute ( "about" , "about" , new {
controller = "Home" ,
action = "about"
} ) ;
context . Routes . MapRoute ( "contacts" , "contacts" , new {
controller = "Home" ,
action = "contacts"
} ) ;
}
public override string AreaName { get ; } = "Home" ;
}Sekarang, Anda bisa melakukan ini tanpa kelas arearegistrationContext yang dibutuhkan
RouteManager . GetProvider ( )
. WithArea ( "Home" )
. WithController ( "Home" )
. withAction ( "" , "index" , "index" )
. withAction ( "about" , "about" )
. withAction ( "contacts" , "contacts" ) ;Atau, jika Anda ingin menggunakan rute dengan nama yang sama dengan tindakan pengontrol yang dapat Anda gunakan:
RouteManager . GetProvider ( )
. WithArea ( "Home" )
. WithController ( "Home" )
. withActions ( "index" , "about" , "contacts" ) ;Itu akan dipetakan ke /indeks, /tentang, /kontak