اذهب إلى المحتوى
  • 0

كيف أضيف الصفحات Views إلى جدول التوجيه في RouteConfig في MVC5؟

Jason

السؤال

Recommended Posts

  • 0

لإضافة صفحات Views إلى جدول التوجيه Routing table أنشئ دالة 

  public static void RegisterRoutes(RouteCollection routes)

في الصف RouteConfig الموجود في المجلد App_Start في MVC

5692d42a88044_RoutConfg.thumb.png.05b6a9

الآن باستخدام  routes.MapRoute حدد اسم ورابط الصفحة والمتحكم الخاص بها (كل صفحة تحتاج لـ routes.MapRoute) ويتم تحديد routes.MapRoute في الدالة RegisterRoutes.

المثال التالي يضيف 3 صفحات Views إلى جدول التوجيه Routing table  في الصف RoutConfig

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "myTemplate", action = "News", id = UrlParameter.Optional }

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "myTemplate", action = "AboutUs", id = UrlParameter.Optional }

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "myTemplate", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

 

تم التعديل في بواسطة Lujain
رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...