views:

48

answers:

2

I'm writing a multi-tenant app that will receive requests like http://www.tenant1.com/content/images/logo.gif and http://www.anothertenant.com/content/images/logo.gif. I want the requests to actually map to the folder location /content/tenant1/images/logo.gif and /content/anothertenant/images/logo.gif

I'm using asp.net Mvc 2 so I'm sure there's probably a way to setup a route to handle this or a custom route handler? Any suggestions?

Thanks!

A: 

Hey,

If I understand correctly, because it's URL rerouting, I don't know that MVC 2 routing handles this. You need IIS routing, which varies depending on the version you have. For IIS 6, there is an IIS resource toolkit that can handle these kinds of request, or there is helicontech.com's ISAPI_REWRITE or Ionic's rewriter at iirf.codeplex.com. IIS 7 has an MS add-on for url routing too, from what I hear, as a separate download.

These tools can actually redirect the URL in the ways you want, as MVC doesn't deal with the URL itself for the web site, but the pages within the URL request. the ISAPI_REWRITE and other tools actually redirect requests to hosts as you mentioned.

Brian
A: 

I created a custom HttpModule that taps into the BeginRequest event and then checks to see what the path is then calles Context.RewritePath

Micah