1

I have an xml file with custom routes that I'm creating routes from on Application_Start in Global.asax. Some of those routes require authentication, some don't. Currently I have "location" entries for all those routes in web.config to control authorization.

I wonder whether there is a way to configure locations on application start at the same time I configure routes, so that I don't need to have entries in web.config.

I'm using ASP.NET WebForms .NET 4.0

Andrey
  • 20,487
  • 26
  • 108
  • 176
  • Are you using plain ASP.Net or ASP.Net MVC? Also, what version of the tech in question? – Basic Nov 17 '10 at 18:26
  • @Basiclife: good point, updated. Thanks :) – Andrey Nov 17 '10 at 18:39
  • No worries. I was hoping you'd say MVC. Unfortunately, I have no experience with routing in WebForms. I'll post a possible alternative solution though... – Basic Nov 18 '10 at 10:41

1 Answers1

0

Try creating your own (or looking at the many open source) sitemap providers. Your sitemap provider can allow you to dynamically change the sitemap nodes based on whatever logic you want and can also allow you to specify roles/users allowed to access each node...

An SO question showing the basic concept is here and a slightly more involved answer is here

That way, you can read your XML to calculate the URLs of the routes, merge it with any existing sitemap definition as appropriate and still get all the ASP.Net security benefits (Security trimming on sitemap, Authorization for URLs, etc.)

This doesn't answer your question directly but I hope this is of some help.

Community
  • 1
  • 1
Basic
  • 26,321
  • 24
  • 115
  • 201
  • I'm not using sitemap, so it won't help me. – Andrey Nov 22 '10 at 16:16
  • Fair enough, I can't think of another simple solution. Is there any reason why you're not using a sitemap? It provides a lot of nice integration and time-aving throughout your project - I've yet to find a reason not to have one... – Basic Nov 23 '10 at 01:49
  • I'm not using sitemap for one reason - each parent node has to have the same url as the first child node. Site map requires every node to have a unique URL, as far as I remember - at least it did at the time I last checked, two years ago. Plus, I have some custom conditions I check for each node, so I pretty much have my own site map, just not the asp.net one – Andrey Dec 03 '10 at 02:58