or you you can add a httpModule which handles every asp.net request:
(I am using this class in my community, every user gets a domain: http://scorpion4000.unityone.at)
Public Class UrlRewriting
Implements IHttpModule
Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
AddHandler app.BeginRequest, AddressOf ppBeginRequest
AddHandler app.EndRequest, AddressOf ppEndRequest
End Sub
Public Sub Dispose() Implements IHttpModule.Dispose
End Sub
Public Sub ppBeginRequest(ByVal s As Object, ByVal e As EventArgs)
Dim app As HttpApplication
Dim urlArr() As String
app = CType(s, HttpApplication)
Dim strHostDomain As String = app.Context.Request.ServerVariables("SERVER_NAME")
urlArr = strHostDomain.Split(".")
If urlArr.Length = 3 Then
If urlArr(0).Substring(0, 3) = "www" Then
' do nothing here .. normal site
End If
If urlArr(0).Substring(0, 3) = "blogs" Then ' Subdomain Blogs: http://blogs.mysite.com
app.Context.RewritePath("/blogs/Default.aspx")
' app.Context.Request.Url.PathAndQuery = if you need the querystring
End If
If urlArr(0).Substring(0, 3) = "photosite" Then ' Subdomain Blogs: http://photosite.mysite.com
app.Context.RewritePath("/photosite/Default.aspx")
' app.Context.Request.Url.PathAndQuery = if you need the querystring
End If
End If
End Sub
Public Sub ppEndRequest(ByVal s As Object, ByVal e As EventArgs)
End Sub
End Class
scorpion4000 post is excellent to handle subdomains issue creation. There is no way to do physical (Real) subdomain without using the WMI and you should have administrative privileges on the server.
I too had problems with web config but i changed it accordingly.
see this link : http://www.worldofasp.net/tut/HttpHandlers/Using_HttpHandlers_and_HttpModules_in_your_ASPNET_Websites_90.aspx
add the given code in aap_code and aap_code acts as assembly name .
Please tell how to enter this Url Example : training.abc.com and get into debugging mode. Its needs wild card entry on dns server ? Or we have to create a separate sit for trainig and make virtual directory on iis ? please help me out ...
bapun2k2
Member
5 Points
7 Posts
Creating a subdomain
Feb 08, 2007 05:14 AM|LINK
Hi Every One
actually i want to create a sub domain in my application.
My domain is ePayroll and inside this i want to create a sub domain named eilisys
I dont know How to do this,Can Any body help me out....
thanks in advance
Saroj nanda
Saroj K. Nanda
Software Engineer
Eilisys Technologies Pvt Ltd.
scorpion4000
Member
44 Points
13 Posts
Re: Creating a subdomain
Feb 10, 2007 07:18 PM|LINK
in iis you can add more websites (for example: website 1 handles: www.mysite.com and website 2 handles: blogs.mysite.com)
look here: http://www.no-ip.com/support/guides/web_servers/virtual_hosting_iis.html
or you you can add a httpModule which handles every asp.net request:
(I am using this class in my community, every user gets a domain: http://scorpion4000.unityone.at)
Public Class UrlRewriting Implements IHttpModule Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init AddHandler app.BeginRequest, AddressOf ppBeginRequest AddHandler app.EndRequest, AddressOf ppEndRequest End Sub Public Sub Dispose() Implements IHttpModule.Dispose End Sub Public Sub ppBeginRequest(ByVal s As Object, ByVal e As EventArgs) Dim app As HttpApplication Dim urlArr() As String app = CType(s, HttpApplication) Dim strHostDomain As String = app.Context.Request.ServerVariables("SERVER_NAME") urlArr = strHostDomain.Split(".") If urlArr.Length = 3 Then If urlArr(0).Substring(0, 3) = "www" Then ' do nothing here .. normal site End If If urlArr(0).Substring(0, 3) = "blogs" Then ' Subdomain Blogs: http://blogs.mysite.com app.Context.RewritePath("/blogs/Default.aspx") ' app.Context.Request.Url.PathAndQuery = if you need the querystring End If If urlArr(0).Substring(0, 3) = "photosite" Then ' Subdomain Blogs: http://photosite.mysite.com app.Context.RewritePath("/photosite/Default.aspx") ' app.Context.Request.Url.PathAndQuery = if you need the querystring End If End If End Sub Public Sub ppEndRequest(ByVal s As Object, ByVal e As EventArgs) End Sub End ClassUnquaLe
Member
67 Points
14 Posts
Re: Creating a subdomain
Apr 10, 2007 01:11 PM|LINK
Hello scorion4000,
Thank you for your httpModule. I have implemented that to my website.
But it doesnt rewrite the path for blogs.mysite.com
Is there another configuration for this issue ?
Thank you
Raymond Wen...
All-Star
32101 Points
3764 Posts
Re: Creating a subdomain
Apr 11, 2007 06:04 AM|LINK
A custom httpModule must be registered in web.config to make it take effect.
<system.web>
<httpModules>
<add name="LogHttpModule" type="LogHttpModule"/>
</httpModules>
Hope it helps.
smiling4ever
All-Star
15531 Points
3063 Posts
Re: Creating a subdomain
Apr 15, 2007 05:04 PM|LINK
Hi there,
scorpion4000 post is excellent to handle subdomains issue creation. There is no way to do physical (Real) subdomain without using the WMI and you should have administrative privileges on the server.
Google it or seach MSDN for WMI.
Regards
nomi123
Member
2 Points
1 Post
Re: Creating a subdomain
Apr 24, 2007 01:55 PM|LINK
Hi
I made a class with this code. Kindly guide me how can I use this with my application.
Second thing is that
<
httpModules><
add name="LogHttpModule" type="LogHttpModule"/></
httpModules>is also not working in my web.config file any special reason ? Please guide me as I am new to ASP.net and I have this very urgent work
Thanks
scorpion4000
Member
44 Points
13 Posts
Re: Creating a subdomain
Apr 25, 2007 06:39 AM|LINK
replace
togius
Member
33 Points
56 Posts
Re: Creating a subdomain
Mar 24, 2008 12:38 PM|LINK
this is an brilliant example thanks. But how can i use this class... I couldn't success
togius
Member
33 Points
56 Posts
Re: Creating a subdomain
Mar 24, 2008 12:39 PM|LINK
this is an brilliant example thanks. But how can i use this class... I couldn't success
manish_manu04
Member
4 Points
6 Posts
Re: Creating a subdomain
May 23, 2008 12:43 PM|LINK
Hi,
I too had problems with web config but i changed it accordingly.
see this link : http://www.worldofasp.net/tut/HttpHandlers/Using_HttpHandlers_and_HttpModules_in_your_ASPNET_Websites_90.aspx
add the given code in aap_code and aap_code acts as assembly name .
Please tell how to enter this Url Example : training.abc.com and get into debugging mode. Its needs wild card entry on dns server ? Or we have to create a separate sit for trainig and make virtual directory on iis ? please help me out ...
SubDoamin creation