0

I need to implement route mapping in asp.net web application. there are many tutorials telling how to do it in mvc. but i need to do it in web pages.

I have done it successfully for parent domain. my website also handles fake domain(wild card dns) as well, I need to map routes for subdomains as well.

http://mysite.com/login is mapped to http://mysite.com/default.aspx

but , now i want to map http://login.mysite.com to http://login.mysite.com/login.aspx and http://signup.mysite.com/ to http://signup.mysite.com/signup.aspx

any idea how to do it?

muhammad kashif
  • 2,566
  • 3
  • 26
  • 49
  • why do you need to have a route ? I guess simply mapping the web app root directory default document to default.aspx would work. – jbl Mar 01 '13 at 12:26
  • I have edit the question , It will be make things clear. – muhammad kashif Mar 01 '13 at 12:32
  • I guess I'm missing something. Why don't you set default document to login.aspx for login.mysite.com and to signup.aspx for signup.mysite.com/ ? – jbl Mar 01 '13 at 12:40
  • basically I do not have physical sub domains, they are faked using wild card dns. there will be many more fake domains . hence I only have one web application with many fake sub domains. And I have set default document for my web application , but now i want to map my fake sub domains to different aspx pages. – muhammad kashif Mar 01 '13 at 13:24
  • thx for the explanation. this may be of some help I guess : http://stackoverflow.com/q/278668/1236044 – jbl Mar 01 '13 at 13:46

1 Answers1

1

Are you sure you need routing for this? It seems your just want redirection which can be handled by IIS or web.config.

If you really need routing, there are plenty of articles on both MVC as well as web forms, just search. In MVC you do it using the RouteConfig.cs file and in web forms you do it via Global.asax.cs file (or some helper referenced from global.asax.cs). Basically in web forms you add your routes to the RouteTable.Routes collection.

The code will look something like this (untested):

routes.MapPageRoute("",
"login",
"~/default.aspx");

Here are a couple of links which can get you started on routing:

  1. Walkthrough: Using ASP.NET Routing in a Web Forms Application
  2. RouteTable.Routes Property
joym8
  • 4,014
  • 3
  • 50
  • 93