Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General questions - not an issue but seeking more info #9

Open
seanyeomans opened this issue Apr 17, 2013 · 4 comments
Open

General questions - not an issue but seeking more info #9

seanyeomans opened this issue Apr 17, 2013 · 4 comments

Comments

@seanyeomans
Copy link

Does the EditableRoutes process presume to replace the Routes table. or does it augment? Do you run it before or after the main Routes are defined elsewhere?

I technically have the pkg 'working', in that it is executing (from Global.asax.cs) and updating the Routes based on ./Config/Routes.cs, but it's wiping out the Routes that have collected up to this point.

It seems that the Collection data is not being passed into the Routes.RegisterRoutes() method when the file is processed. What might I be missing, do you think?

@haacked
Copy link
Owner

haacked commented Apr 17, 2013

Hi @seanyeomans, yep, it reloads the route. You can see that here: https://github.com/Haacked/RouteMagic/blob/master/src/RouteMagic/RouteRegistrationExtensions.cs#L27

The reason is that when you change the file, we don't diff the changes. We just take the easy way out and reload.

In theory, we could be smarter about this and not reload them, but just apply the changes. If that's something you'd want to take a crack at, I can help you with the pull request. 😄

@seanyeomans
Copy link
Author

Turns out we were able to circumvent this happening by running a call to our own routes inside the RegisterRoutes extension, instead of loading them from Global.asax,

The idea is to incorporate routes from a DB table, allowing the users to add new ones through a cms. fun stuff.

public void RegisterRoutes(RouteCollection routes)
{
   MvcApplication.RegisterRoutes(routes); // fire up tertiary routes

   //loop through DB retrieved routes
 .......
    routes.Add("", new LegacyRoute("mooo", "LegacyExternal", 
      new { externalUrl = "http://www.facebook.com/pages/<snip>" }));

  ......
   //endloop
}

edit:
I don't know why this post looks all weird....

@haacked
Copy link
Owner

haacked commented Apr 18, 2013

Cool! And that sticks around if you then edit the routes in Config/Routes.cs?

p.s. The reason the formatting was off was you didn't indent the first line four spaces. I edited it to fix it by using the triple tick mark syntax instead. It's a better way to add code blocks to a comment. :)

@seanyeomans
Copy link
Author

yessir, it sticks.

In theory Config/Routes.cs will never be edited again, but rather the routes are populated on the fly from a db IService call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants