Click here to Skip to main content
13,902,139 members
Rate this:
Please Sign up or sign in to vote.
See more:
I've URLs in my website and which are using query string values For example:

Please suggest how it can be accomplished without actually creating subdomains on server ..

I've IIS 7.5 installed on server machine and using 4.0.
Updated 2-Apr-16 2:03am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

protected void Application_BeginRequest(Object sender, EventArgs e)
    var SubDomain = GetSubDomain(HttpContext.Current.Request.Host);
    // this is a simple example, you can place your variables base on subdomain
       RewritePath(HttpContext.Current.Request.Path + SubDomain + "/", false);  

// from :
private static string GetSubDomain(Uri url)
  string host = url.Host;
  if (host.Split('.').Length > 1)
    int index = host.IndexOf(".");
    return host.Substring(0, index);

  return null;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190306.1 | Last Updated 2 Apr 2016
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100