Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 - Controller returns view from the Root and not from Area
    primarykey
    data
    text
    <p>I am trying to achieve a multi tenant MVC3 application. All the url requests including subdomain requests are directed to the main application. Solution is having the default main controllers and an area named "Clients". So there are 2 routes. </p> <p>This on in the clientarea</p> <pre><code>context.MapRoute( "Client_default", "{controller}/{action}/{id}", new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional }, new {controller = new ClientAreaConstraint()}, new[] { "MainApp.UI.Areas.Clients.Controllers" }); </code></pre> <p>This in the global asax</p> <pre><code>routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional }, new[] { "MainApp.UI.Controllers" } ); </code></pre> <p>One for the area and one for the main one. In the route of the area, I have added a route constraint which checks whether the url has a subdomain to it, If yes it returns true.</p> <pre><code>public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var url = httpContext.Request.Headers["HOST"]; var clientName = url.Split('.')[1]; return clientName != "mainsite"; } </code></pre> <p>This works and the area controller is getting the subdomain requests. But when i try to call return View(). It looks for the View in the main folder and not in the Area folder. My url looks like this <a href="http://www.client.mainsite.com/" rel="nofollow">http://www.client.mainsite.com/</a> and it doesn't have the area name. Is it because of that ? What could be the problem ? Please help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload