PDA

View Full Version : Accessing SubDomains


Bosco
04-21-2010, 03:15 PM
I'm having trouble accessing a subdomain. I purchased the unlimited subdomains and created a simple web app project for the root folder (softingenuity.com). I created a folder named bma and published another simple web app that just displays a label stating where I am.

softingenui is my root folder.
softingenuity.com is my domain.

I used the following code in my default.cs file:

protected void Page_Load(object sender, EventArgs e)
{

string subDomain = "bma";
string subDomainUri = @"/softingenui/Default.aspx";

if (Request.ServerVariables["SERVER_NAME"].ToLower().Contains(subDomain))
Response.Redirect(subDomainUri);
}

When I type in softingenuity.com I get the page I expected but when I type in bma.softingenuity.com, I get a page not found error.

any help would be appreciated.

joer
04-21-2010, 06:52 PM
If you are trying to have your subdomain "bma.softingenuity.com" reference your application within the "bma" folder, your code should reference "bma/Default.aspx".

Also make sure that you have set your subfolder "bma" as a web application through your hosting control panel.

Bosco
04-22-2010, 10:29 AM
Now I can't load the root folder app or the bma app. Do you see anything in the code that would cause this. I am new to asp.net and c sharp.

softingenui or root folder default.cs:

namespace WebApplication13
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

string subDomain = "bma";
string subDomainUri = @"bma/Default.aspx";

if (Request.ServerVariables["SERVER_NAME"].ToLower().Contains(subDomain))
Response.Redirect(subDomainUri);
}
}
}




bma folder default.cs:

namespace WebApplication14
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

Bosco
04-22-2010, 10:49 AM
Do you have a working example of the code I need to use to get this working?

Does it matter that the root folder app is a web app and not a web site?

Cort

Bosco
04-22-2010, 02:29 PM
Thanks, I think I have the simple version working. Do you have an example of redirecting to web app in a subdomain from an HTML file?

Thanks in Advance

joer
04-22-2010, 05:24 PM
Sorry for the delay. You may view our sample code which is in ASP / ASP.NET we offer on our KB article here (http://support.discountasp.net/KB/a369/how-to-redirect-a-subdomain-to-a-subdirectory.aspx)