ajma
ajma

Reputation: 12206

Can have part of the domain name as a parameter in my routing rules?

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?

Upvotes: 2

Views: 410

Answers (3)

Pavel Chuchuva
Pavel Chuchuva

Reputation: 22465

See ASP.NET MVC Domain Routing by Maarten Balliauw.

Upvotes: 1

Parsa
Parsa

Reputation: 1065

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

Upvotes: 1

Schmidty
Schmidty

Reputation: 1899

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.

Upvotes: 1

Related Questions