Routing MVC3 with WebForms

I have a solution using WebForms.Net 4.0. I plan to use MVC3 in the same solution. I followed Scott Hanselman's blog and everything went around.

I must admit that I am completely new to this. However, it looks like I'm missing out on most of how routes really work in relation to namespaces.

Currently, our solution has the following:

WebApplicatin: 
  Accounting
      Receivables
         ReceivablesGrid.aspx
         ReceivableForm.aspx
      Payables
        PayablesGrid.aspx
        PayablesForm
 ..etc.

So you can request a page using

Domain/Accounting/Receivables/ReceivablesGrid.aspx
Domain/Accounting/Receivables/ReceivableForm.aspx?Key=1
Domain/Accounting/Payables/PayablesGrid.aspx
Domain/Accounting/Payables/PayablesForm.aspx?Key=1

....

I plan to add another layer similar to MVC.

WebApplicatin: 
      Accounting
          Receivables
             ReceivablesGrid.aspx
             ReceivableForm.aspx
             Mobile
              Controllers
                ReceivableConroller.cs
              Models
              Views
                Receivables
                   Index
                   Update
                   Edit
                   Create
          Payables
            PayablesGrid.aspx
            PayablesForm
            Mobile
              Controllers
                PayablesConroller.cs
              Models
              Views
                Payables
                   Index
                   Update
                   Edit
                   Create

     ..etc.

, . , . , , , , ​​ . , , , Views, Models, .

Global.asax :

routes.MapRoute(
      "AccountingReceivablesMobile", // Route name
      "Accounting/Receivables/Mobile/{controller}/{action}/{id}", 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional });

routes.MapRoute(
      "AccountingPayablesMobile", // Route name
      "Accounting/Payables/Mobile/{controller}/{action}/{id}", 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional });

, , RazorViewEngine. :

base.ViewLocationFormats = new string[] { "~/Accounting/Receivables/Mobile/Views/{1}/{0}.cshtml",
"~/Accounting/Payables/Mobile/Views/{1}/{0}.cshtml"
 };

base.MasterLocationFormats = new[] { "~/Views/Shared/{0}.cshtml"}. 

. , , , webForm. , . , . , ? ? , , , Areas .

,

+5
1

ASP.NET MVC ( Rails MVC) , \controllers, \views \models . , , , , MVC .

, Razor... , , , , , ASP.NET MVC . , MVC.

, ASP.NET WebForms MVC3. (, , ) -, , , - "", .

, , , -/ ( , , -), Ninject IoC, -, MVC, ; App_Start().

, , ReSharper CodeRush, using, .

, , , , , , . MVC , / - ; , - , , MVC. , .

, , Razor. , - , MVC. , ?

, , , . 51Degrees.mobi ASP.NET ASP.NET MVC. , .

+4

All Articles