how to create sub-domains - asp.net

i am going to create some sub-domains on my website.
when i create a sub-domain i must define a directory that sub-domain will refer to newly created sub-domain. but i want a different solution.
i want to detect when a user enters a URL , which sub-domain is used and then do some operation for each special sub-domain.
for example if website user entered a.mysite.com
i extract "a" sub-domain from URL and then without redirecting webpage i load some data in page.
please help me how i do these,on both web-server and localhost?

In general your application doesn't care about the host name, so you have to configure your IIS to handle all requests.
Production only: Create a wildcard DNS record for your domain (e.g. *.domain.tld)
Your IIS site should have no explicit bindings, so that ALL incoming requests hit this application (other sites should still work fine!).
After this you can check the HttpContext.Current.Request.Url and extract the requested subdomain.

Related

Pointing domain from one cPanel account to another

I manage a hosting server using WHM. I have two cPanel accounts on this server, one for exampletest.com (account name is exampletest) and one for example.com (account name example). We have a Wordpress site that was working well at exampletest.com but we keep running into problems when we try to migrate it to example.com. I believe it has to do with one WordPress plugin that doesn't migrate well.
So we had the idea to simply take the example.com domain and point it to the exampletest cPanel account, then update the domain for WordPress in the database. However, one potential issue I can see is that we have many active email addresses on the example account. I fear that associating the example.com domain to the exampletest account will break the email addresses.
Keeping the above in mind, I have a couple questions:
Will associating the example.com domain to the exampletest account break the emails? If so, is there a workaround (moving the email addresses to the new account somehow?)
Is there a better way to go about doing this that I'm not thinking of?
The best way of transferring your wordpress site would be to copy the files, create a database user with the same login details and import the database. Wordpress shouldn't be able to tell the difference.
One way would be to assign a static IP address to exampletest and point example.com's A record to that IP.
Due to the way WHM's DNS and port binding is set up it will not let you set up the same domain on two seperate accounts.
You could treat www. as a seperate subdomain and add the subdomain www.example.com to exampletest as an addon domain and remove the www A record from example first. Redirect all web traffic from example.com to www.example.com or use another sub-domain such as www2.
Another option would be transfer the emails, you can either use the transfer tools in WHM > Transfers or use http://imapsync.lamiral.info/

multiple domain url routing in asp.net 4

Can Asp.Net 4 Webforms handle url routing for differing domain names?
Ex. www.abc.com
www.admin.abc.com
www.domainname.com
www.admin.domainname.com
I would like to make a single app to handle the requests coming from the above URLs.
Most of the scenarios I have found point to having url routing based on a single domain and multiple web pages.
Thanks!
Yes it can (If I understand your using of the word URL Routing correctly).
Simply set a host-header entry for the application for each of the domains you want to support. You can do this in the IIS.
As a result www.abc.com www.admin.abc.com www.domainname.com www.admin.domainname.com all point to the same web application. Be aware, that sharing a session between multiple domain names might become a problem. (If the user starts surfing with www.abc.com and later uses www.domainname.com)
Another approach would be to use the canonical hostname rule for the IIS 7.5 URL Rewrite 2 Module. That results in having only domain that is visible for the users. E.g. www.domainname.com/myFooPage gets redirected to www.abc.com/myFooPage)
This might be a good approach for SEO

Moving a domain

Hi I am hoping for some advice.
I have just managed to get a .co domain so I wish to point all requests from my .co.nz domain to the .co
I am running IIS7.5
I have created a services site e.g. services.mydomain.co.nz and the website mydomain.co.nz both are running on their own website and app pool.
At the moment I don't want to break any of the web services so I want to keep the services site as services.mydomain.co.nz but I want to automatically redirect website users to the .co domain instead of .co.nz
So far I have added a new host header in IIS and this allows me to hit the website using the .co domain but I can still hit the site using .co.nz
Do I need to create a url rewrite function to help with this?
You can use http redirection in IIS to direct all requests at the old domain to exactly the same path at the new domain.
You want to choose options as I have in this photo:
Include the full base url to the new site, ending at the slash after the domain name. then leave the other options as I have them; this way, any request at the old domain will be sent a 301 "permanent" code to redirect to the new, equivalent page on the new site.
Note that it's important that you do not check the first of those checkboxes under 'Redirect Behavior'; that will make it send all requests to the home page of your site, rather than to the same path url.
This should be on a separate IIS site, by the way.

How to Route URL from one domain to another

I am an C# ASP.NET developer. I am trying to route URL from one domain to another using Godaddy IIS Virtual dedicated server or Dedicated server for ASP.NET.
For example I have a website application for client_A in my server which is intended to be use by multiple clients with different products.
An example URL: www.myserver.com/client_A/product/bear/?productid=1 or using pretty URL www.myserver.com/A_Application/product/bear/1
I would like to setup for my client to point to client_A using his/her domain.
My Client example URL will be: www.hisserver.com/product/bear/?productid=1 or using pretty URL www.hisserver.com/product/bear/1
Thanks!
The simplest solution would be for you client to set up their domain to simply point to your server, then use Apache virtual hosts to point that domain to the directory in question. I'm not sure if godaddy allows multiple virtual hosts like that, so you could also do it with a mod_rewrite based on the incoming Host.

How do I allow a user to use their own domain name for a hosted service?

I am working on an ASP.NET MVC web app that allows people to publish content, but other than publish the content to a remote server, I want to allow people to use their domain name directly. For example, the user "Tom" can have his domain name TomSite.com point to http://www.mywebapp.com/user/tom, but the sub path will also be mapped. For example, TomSite.com/path will be mapped to www.mywebapp.com/user/tom/path, and this is transparent to the web visitor. The visitor will never see "mywebapp.com" anywhere on TomSite.com.
I think Smugmug.com provides such service, to allow people to use their own domain name for the photo portfolio. I want to achieve the same result.
How can I do this? Thanks!
This require multiple steps.
First you have to find out how your users will configure their domain to have a CNAME record for you site. You can archieve this in a number of ways where the best is education. Making partnerships with hosting providers requires a great deal of volume.
In IIS this will require you to either add each host name manually (however this could also be archieved through scripting) or have a dedicated IP address only for you site.
There is also a need for the domain to be associated with an account. The user has to add this themselves and you would probably add a check in the interface which confirms the domain is pointed at your server. The code for this would look like (remember to include the System.Net namespace).
if (Dns.GetHostEntry("www.user.example.com").HostName == "www.example.com")
{
// www.user.example.com is a CNAME for www.example.com
}
In you ASP.NET MVC project you need to implement routes for this particular purpose. Create a custom class inheriting from Route which also takes the domain into account.
Smugmug (who you mentioned) get their users to setup a CNAME record that will alias the url for the user's personal photo section. For most users this will probably require them contacting their host or looking up help files in order to get it all setup.
So, while www.tomsite.com could transparently serve up pages hosted at www.mywebapp.com the users will have to put some kind of effort in. To make it a completely seamless you will need some kind of arrangement with the users web host (Smugmug appear to have such an arrangement with GoDaddy).
I doubt you will be able to setup such integration with all the web hosts out there, so the only complete solution would be to host the websites of your users yourself (I do not know enough about your wider situation to determine if that is a reasonable solution).
Note: setting up an alias on your own web server (aka url rewriting) will not work, unless you host their site yourself, as obviously people fetching from your user's domain will not arrive at your server in the first place.
Have each customer's friendlyname pointed at the external ip address of your webserver.
Use IIS to resolve the friendlyname specified in the host header request to the logical website you want delivered to that friendlyname. IIS will happily map both a website and a virtual folder to the same folder in the file system. Create a website for each customer. Then bind that website to the customer's friendlyname.
Remember to map the default website only to your own friendlyname(s). If you leave it in promiscuous mode (mapped to "*") results will be unpredictable.
To set host header mapping
Select Default Web Site under the Sites node. In the Actions pane at top right click on Bindings... to open the Site Bindings dialog. There will be a list of bindings, probably containing a single entry that says http * 80. Select this and click the Edit... button. Set Host name to your own friendlyname.
Run IIS7 Manager and for each customer site create a website under the Sites node. Set both file path and host header binding while you are creating each web site. Obviously the host header binding (host name) should be that customer's friendlyname.
Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?
See it like an alias :)
Ofcourse, since you're asp.net/windows based, i think you'll have to digg deep into IIS to automate this kind of stuff. If you were on apache it would be adding 3 simple lines to httpd.conf.

Resources