Asp.Net Mvc Areas'ta Maproute Kullanımı
ASP.NET MVC AREAS'TA MAPROUTE KULLANIMI

MVC | Ali Yasin Doğan | 01.02.2019 | 1757

Asp.Net Mvc Areas'ta MapRoute Kullanımı

  
namespace projeadi.Areas.Admin
{
    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
               name: "Admin_Login",
               url: "Admin",
               defaults: new { controller = "Login", action = "Index" }
           );

            context.MapRoute(
                name: "Admin_default",
                url: "Admin/{controller}/{action}/{id}",
                defaults: new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
//controller
 public class LoginController : Controller
    {
         
        //GET: Admin/Login
        public ActionResult Index()
        {
            return View();
        }
       [HttpPost]
        public ActionResult Index(User u)
        {
            //Kodlar....
            return View();
        }
     }

Normalde Görünecek URL:
www.domain.com/Admin/Index
Düzenlemeden Sonra Görünecek URL:
www.domain.com/Admin
 




 Etiketler:  asp.net mvc areas maproute