views:

739

answers:

2

Hi, i'm new to development with .net and working on a personal project. my project will allow users to create their own simple mobile site.

I require to write http module that will handle pseudo subdomains.

I already setup my dns wildcard to domain so sub.domain.com xxx.domain.com etc points to same application. I want to be able to extract sub and ID parts from sub.domain.com/pageID.html url and load settings of page from database server in order to build and render it to client.

i can do it with urlrewrite tools like isapirewrite but i want my application to be independent from OS so that server doesnt require installation of any 3rd party app.

is it possible to do it with http handlers? can anyone post sort of sample?

thanks

+3  A: 

You can check the domain at any time. Where to do it dependings on your application's goals. E.g. if you want to serve different pages depending on the domain you could do like this:

public class MyModule : IHttpModule
{
 public void Dispose()
 {
 }

 public void Init(HttpApplication context)
 {
  context.BeginRequest += context_BeginRequest;
 }

 void context_BeginRequest(object sender, EventArgs e)
 {
  HttpApplication app = sender as HttpApplication;
  string host = app.Request.Url.Host;
  if(host == "first.domain.com")
  {
   app.Context.RewritePath("~/First.aspx");
  }
 }
}
Cristian Libardo
A: 

hello i need help in creating sub domains. if any one worked on the sub domains please help me.

sai
if you have question, post a question not an answer
Andrija