dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

nesting in routing #241

Closed behnamshateri closed 4 years ago

behnamshateri commented 4 years ago

@dsuryd I'm having trouble with nesting of the API for routing. I use an AppLayout view which consists of the Header Sidebar and the content. All my website routes are in Applayout:

public AppLayout()
{
    this.RegisterRoutes("", new List<RouteTemplate>
    {
          new RouteTemplate("Home") { UrlPattern = ""},
      new RouteTemplate("Contact") { UrlPattern = "contact"},
      new RouteTemplate("Aabobank") { UrlPattern ="about" },
     }
}

I wanna have my admin panel, that i want to use nesting routing in dotnetify, I register my admin url AppLayout vm:

new RouteTemplate("MyBotBank", "MyBotBank.js") { UrlPattern = "mybotbank", VMType = typeof(MyBotBank.MyBotBank) },

And in MyBotBank Vm, i want to register my admin route that inherited from mybotbank url:

public MyBotBank()
{
     this.RegisterRoutes("mybotbank"), new List<RouteTemplate>
     {
           new RouteTemplate("MyBotBankHome") { UrlPattern = "", ViewUrl = "MyBotBank"},
           new RouteTemplate("Invite")  { UrlPattern = Invites },
     });
}

and i connect all of my react page to related Vm, also myBotBank, invite and ... and also assign my page to window. but when i try to access the :

host.com/mybotbank/invite

dotnetify does not load invite page,how can i deal with? and also how can i implement 404 route.

dsuryd commented 4 years ago

new RouteTemplate("Invite") { UrlPattern = Invites },

what's in Invites ?

Enable dotnetify.debug then check the log. Compare it with the log you see in the nested routing example (book store) in the dotNetify website. Success would be indicated with router> routed output.

and also how can i implement 404 route.

404 is not currently supported, but I'm in the middle of making fixes and improvements to the routing logic that will include this.

behnamshateri commented 4 years ago

@dsuryd: Invite is an admin page that has its own address and also its own react page. i want to write all of my admin address in the form of nesting route that i explain above.

dsuryd commented 4 years ago

Latest release now supports 404 error handling, among other routing enhancements.

behnamshateri commented 4 years ago

thanks dear @dsuryd for supporting 404. Another problem is nesting routing that describe in above, do you have any approach for handle this methodology?

dsuryd commented 4 years ago

I'm not clear on what the issue is with your code. Could you start from the routing demo code below and show me how to reproduce the issue there: https://github.com/dsuryd/dotNetify/tree/master/Demo/React/LazyLoadRouting