1

I would like to have a single asp mvc application that runs under www.mysite.com for all guests. Once the user logs into the website I would like to use the subdomain my.mysite.com as the domain they will use across the site within the same application. Once they log out I would like them to go back to www.mysite.com.

Is this possible? I would assume so but I have not found any information on this setup specifically.

I can see that it is possible to use sub-domains in MVC with more than one application but I do not wish to create two applications since all the functionality is contained within this one.

David Hirst
  • 1,890
  • 2
  • 22
  • 31
  • similar question http://stackoverflow.com/questions/7033292/mvc3-forms-authentication-across-sub-domains-in-single-application – user1666620 Jul 07 '14 at 11:03
  • unfortunately the answer is again about using two applications – David Hirst Jul 07 '14 at 11:08
  • WHat you can do is to create a custom routing for authenticated users – Arijit Mukherjee Jul 07 '14 at 11:11
  • @Arijit - Do you have an example? – David Hirst Jul 07 '14 at 11:11
  • AFAIK 1) use Response.Redirect() on Application_BeginRequest. Problem is that will slow down little bit your application (because it'll be done by MVC framework when it may be done by IIS). 2) Do it with IIS, if you can setup https for logged in users and http for guests then it'll be pretty simple with IIS url rewrite. – Adriano Repetti Jul 07 '14 at 11:13

1 Answers1

1

You can achieve it by using RoutingConfig or AttributeRouting

Here are few example for the same:

  1. Marteen Blog The most relevant and easy to implement

  2. ASP.NET Forum

  3. Attribute Routing

  4. Blog by Stephen

  5. SO Thread 1

  6. SO Thread 2

Community
  • 1
  • 1
Arijit Mukherjee
  • 3,817
  • 2
  • 31
  • 51