Asp.net 3.5 Sp1 Sub-Domain routing?
Asked Answered
D

1

0

I was wondering is there is a way to introduce sub-domains in Asp.net 3.5 routing

All i found as this http://blogs.securancy.com/post/ASPNET-MVC-Subdomain-Routing.aspx

But i was looking for something more complex to allow doing wild-card sub-domains

Any Help ?

Duplicator answered 19/5, 2009 at 8:26 Comment(0)
A
0

Should be no problem, even with that sample. In this case, just add a wildcard to your DNS "*.yourdomain" and use the 'default' statement from the switch to handle wildcards.

In other words, change the sample for the Global.asax to something like:

                default: 
                returnValue = new RouteData(this, new MvcRouteHandler());
                returnValue.Values.Add("controller", "MyControllerName"); 
                returnValue.Values.Add("action", "MyActionName");

                // for example, provide the entered subdomain as parameter;
                returnValue.Values.Add("MyActionParameterName", subDomain); 
                break;

And don't forget: add a wildcard to your DNS. It shall not be possible to test subdomains on localhost, though.

Acridine answered 19/5, 2009 at 12:34 Comment(2)
But i guess in that case the url will be something like this example.yourdomain/MyControllerName/MyActionName/… Right ... which is the same point in the article i linked in my questionDuplicator
and if am right then there is no point of using the subdomain if i am passing it as a parameter.Duplicator

© 2022 - 2024 — McMap. All rights reserved.