PDA

View Full Version : چگونگی اجرای index درون area??



rahjoya
شنبه 05 تیر 1395, 13:20 عصر
سلام.
آیا راهی هست که با اجرای برنامه از همان ابتدا ایندکس درون area اجرا شود؟
الان با اجرای برنامه پیغام زیر داده میشود
Server Error in '/' Application.
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml


تیظیمات areaRegisteration:
context.MapRoute( "SomeArea_default", "SomeArea/{controller}/{action}/{id}",new { controller = "SomeController", action = "Index", id = UrlParameter.Optional } );
تنظیمات Route config:
routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional}

parsdarab
چهارشنبه 09 تیر 1395, 14:40 عصر
سلام

برای اینکه صفحه اول سایت با یکی از ویو های داخل area شروع بشه باید در قسمت AreaNameAreaRegistration

کد به صورت زیر تغییر کنه


public class adminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "admin";
}
}

public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"admin_default",
"{controller}/{action}/{id}",
new { controller = "About", action = "Index", id = UrlParameter.Optional }
);
}
}

فقط کافیه که نام کنترلر اضافه شود
و نام area که به صورت ثابت رشته هس پاک کنید