views:

91

answers:

3

I'd like to have a routing rule that accepted part of my domain name as a parameter. For example:

{name}.mydomain.com/photos/{id}

Is this even possible?

+1  A: 

It wouldn't be possible since the {name}.mydomain (a valid name instead of {name}) is the Authority part of a Uri. The routing can be performed only on the PathAndQuery part of a Uri.

Edit: I was somehow wrong, take a look at this answer: Manipulating Url structure

Parsa
+1  A: 

I have had a similar issue in using asp.net mvc, but with using the whole domain instead of just the subdomain. What we used was a custom route constraint to determine which controller to go to (domain determined controller on our project). Then in the controller we used the normal asp.net request.url properties to take an action. This may or may not help depending on your exact requirements.

schmidty
A: 

See ASP.NET MVC Domain Routing by Maarten Balliauw.

Pavel Chuchuva