0

VS2013 update 4, MVC5

Still relatively new to MVC. To divide functional domains within an MVC project the use of Areas seems clear from these posts (olderSOlink, newerMVC5link).

Is there ever a reason that sub-domains would be integrated as part of a solution involving different functional domains of a given MVC project? I don't have a reason to want to make use of sub-domains, I'm just asking because I don't know if there is some advantage I should know about.

Is it even possible without great difficulty? For example, can logons transfer across sub-domains? Would there be other difficult issues to address?

At present the project I am building is 'relatively' small and will have around 5 major domains so I'm assuming Areas is the best architecture to isolate these domains, but I wanted to ask for guidance before I go too far and make decisions that would make the use of sub-domains difficult in the event there is a compelling reason to use them in a single MVC project.

Community
  • 1
  • 1
Alan
  • 1,587
  • 3
  • 23
  • 43

1 Answers1

1

I generally use subdomains to separate major application functionality or if I have multiple servers that I want to be on the same domain name.

To answer your login question, if you are using the same application you will remain logged in on the whole domain (depending on your method of using sessions, the cookie will be accessible to the domain as a whole).

If you are questioning using subdomains, they are really just a naming scheme so you could categorize your 5 major applications into one domain with different paths (eg. /portal, /store, /etc..) then later you could point store.domain.com -> domain.com/store. So it's pretty flexible in the end.

Micaiah Wallace
  • 1,101
  • 10
  • 17
  • Thx! Any links that you know of that provide simple examples of doing these things? – Alan Jul 29 '15 at 16:52
  • If you are asking about the subdomain pointing, it depends on your host. If you have godaddy then: (https://www.godaddy.com/help/managing-a-domain-names-subdomains-4080) should help – Micaiah Wallace Jul 29 '15 at 16:54
  • Ah, sorry, wasn't clear. I am well familiar with creating & uploading code to sub-domains. My request for ex was relative to what I must do to architect/setup an MVC application to use sub-domains. What are the considerations regarding different models, making sure views are consistent, how different locations are loaded from the project, etc. I'll add that while reusability is often a concern, not so much for this project, which is why I wondered about the advantages of Areas vs. sub-domains. – Alan Jul 29 '15 at 17:10
  • Oh, gotcha. I can't help with the specifics of that specifically, I did find this link for mapping subdomains to mvc areas though. Hope it helps http://tech.opentable.co.uk/blog/2013/09/25/resolving-domains-to-areas-in-asp-dot-net-mvc/ – Micaiah Wallace Jul 29 '15 at 17:20
  • That last post in the UK suggests that if I use sub-domains, I'll increase issues of site consistency; that author **wanted** to have different looks and feels. But if I'm trying to have a single look and feel, will using sub-domains complicate that for me? – Alan Jul 29 '15 at 18:48
  • If you want the same look and feel you could point all the subdomains to one application then Filter which views and models to use in your controllers by checking the variable `HttpContext.Current.Request.Url.Host` – Micaiah Wallace Jul 30 '15 at 14:52