ASP.Net MVC2 - Areas Question

Soldato
Joined
18 Oct 2002
Posts
16,079
Location
The land of milk & beans
Hey all,

Just looking at the feasibility of a system at the minute. This will be the first time I've used areas in anger, so want to make sure this will work as I want it :)

I'm having a problem with my URLs. Basically, I've got my areas set out something like this:

Code:
+ Admin
	+ Controllers
		PageController.cs
		NewsController.cs
	- Models
	+ Views
		+ Page
			Edit.aspx
			Create.aspx
			List.aspx
		+ News
			Edit.aspx
			Create.aspx
			List.aspx
			
+ FrontEnd
	+ Controllers
		PageController.cs
		NewsController.cs
	- Models
	+ Views
		+ Page
			Index.aspx
		+ News
			Index.aspx
			Archive.aspx

Now, the admin is fine. The URLs here will be something along the lines of http://site.com/admin/news/edit/23/ - all good.

However, the front end will be http://site.com/frontend/news/article-name/.

Is there any way to remove that leading /frontend/ - without having to manually create a route in global.asax each time?
 
I really should hang around the Programming forum more.

Thats a good question, something i'd be interested having a play with. I would have thought setting up an a root route that redirects to that specific area would be first thing to have a play with, so yea you would need that setup in the routing table.

However, what about what would happen when you want the other new areas to be accessable in the same way. Maybe its best to leave the URL with its area as its not really an issue is it?
Another thought i would suggest not having it named frontend, you are kinda restricting your site into two main areas where you may find you want to add more areas later on and so what do you call them? frontend2/3/4? Best to try and use areas in a more sub site application frame of mind. So call the area by is general purpose. What i mean is i would have areas like admin/learning/holidays/entertainment etc. Again its all personal taste and whats required. If you are using mvc2 and areas then your anticipating the site will become rather big, if its going to be simple there really isnt much need for areas in which case place your frontend controllers at the root level leaving just one area which is admin (I thinks thats possible).
FYI i've been on mvc.net since pre beta and finished one site in mvc.net 1, so i'm still learning areas myself which as you know is new to mvc.net 2.
 
Thank spoonjaffa - I've just had a read and it looks like you can use Areas with the MVC1 way of doing it at root level. I assumed it was one or the other.

I'll keep the admin in it's own area and put the web-facing elements at root level.

Cheers for the help.
 
It angers, then saddens me when MS forcefully adopt a design pattern or some common implementation as their own and rename it.

"Areas".. bah :mad: :(
 
Back
Top Bottom