How to create subdomain programmatically in VB.NET
Hi,
I am developing a project in .net and vb.net, offering free web hosting with subdomain,
like Geocities and Tripod.
but i dont know that how to create subdomain programmatically by vb.net coding.
As the user will fill the member forms and will become the member , he will get a url like
http://subdomain.domain.com automatically,
i have no idea about subdomain creation dynamically , got my point
if you have any idea about subdomain creation programmatically in any language or having any general idea help me
Thanx in advance :)
Re: How to create subdomain programmatically in VB.NET
Well, it's not a simple task.
First, make sure you have a wildcard third level domain in your nameserver. Something like this:
*.domain.com CNAME domain.com
domain.com A youripaddress
Then, configure IIS so that it shows your website whenever a request to any.domain.com arrives. I'm not sure it supports wildcards in host header names so I can't really help you here.
Now it's the time to write your httphandler. Create an empty class file in your /App_Code folder like this:
Code:
namespace Yournamespace
{
public class YourHandler : IHttpHandlerFactory
{
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
//handler logic here
return PageParser.GetCompiledPageInstance(url, pathTranslated, context);
}
public void ReleaseHandler(IHttpHandler handler)
{
}
}
}
Finally, add this to your web config:
Code:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="Yournamespace.YourHandler" />
</httpHandlers>
</system.web>
</configuration>
Re: How to create subdomain programmatically in VB.NET
Hey,
To do the configuration of IIS, you will have to use something like WMI. Here is an article about it:
http://msdn.microsoft.com/en-us/library/ms525309.aspx
Gary
Re: How to create subdomain programmatically in VB.NET
Hi Bright,
Thanks for yours reply. We dont have wildcard. We buy from webfusion that domain name. We have user name and password from this site. But we are creating all these things previously i told that using manually in this site. But what our requirement is need to create in programmatically. we have ip address host name, username and password.
Please suggest to me. Hope yours reply.
Thanks
Re: How to create subdomain programmatically in VB.NET
Hey,
It sounds to me what you are trying to do is to automate the manual process that you are having to do through the webfusion web site? Is that correct?
I thought you had your own IIS instance, that is why I suggested what I did.
What I think you are after is something using perhaps an HttpWebRequest to send the necessary POST data to create the sub domains.
Gary
Re: How to create subdomain programmatically in VB.NET
hi gep,
Are you telling using HTTPWebRequest send the necessary post data?
I dont understand what you are telling. Could you please explain to me dude??
Thanks
Re: How to create subdomain programmatically in VB.NET
Hey,
Well can you confirm exactly what you are trying to do.
Regardless of the HttpWebRequest, did what I describe actually sound like what you are trying to do?
Gary
Re: How to create subdomain programmatically in VB.NET
I'm not familiar with webfusion so I don't really know if they'll let you create a third level domain programmatically, expecially if yours is a webhosting plan rather than a virtual private server plan.
You might consider giving up the third level domain and create a folder for each user, instead. It's a perfectly viable option and requires no special configuration for the nameserver or IIS.
Basically, you let your users have this page:
yourdomain.com/username
instead of
username.yourdomain.com
In the end it's just a matter of semantics for your users, but you will benefit from a simplified management if you choose the first.
Even linkedin and facebook use a folder for their users. Mind that this hasn't to be a physical folder as you can show the right content for a user with just 1 page and a httphandler (for rewriting URLs).
Re: How to create subdomain programmatically in VB.NET
Webhosts will not be happy with you programmatically bypassing their control system - what I mean is that they won't allow you to programmatically create subdomains and give you that kind of access to IIS. You'll have to find another way as shown above.
Re: How to create subdomain programmatically in VB.NET
hi gep
yeah you are right. I am doing manually that creating subdomain and mailboxes.
Thats y i m asking, Is it possible to create vb.net coding using webfusion??
Please suggest me. Hope yours reply, it might be helpful to me.
Thanks
Re: How to create subdomain programmatically in VB.NET
Hey,
No, you are not going to be able to programmatically access Webfusion's servers directly, but you "could" to an extent, automate the clicks and posts that you would need to make against the website, using HttpWebRequest.
Whether or not your ISP will like you doing this, is another question.
Gary