1

I want to know how to do forward URL rewriting in ASP.NET web applications. For example creating sub domain type of URL without creating Sub Domain at IIS .

For example if user types

http://subdomain.example.com

I would get this after doing my forward URL rewriting

http://www.example.com/name=subdomain

Is there any way to do this when I have an ASP.NET website?

Patrick
  • 17,669
  • 6
  • 70
  • 85
  • Could this help: http://stackoverflow.com/questions/15248094/how-to-rewrite-url-as-subdomain-in-asp-net-without-actually-creating-a-subdomain/15275533#15275533 ? – cheesemacfly Jun 04 '13 at 14:16

2 Answers2

0

Create an ASP.NET web site and deploy it as subdomain.example.com

This site has one page, default.asp, which contains the single line <% Response.Redirect("www.example.com/name=subdomain") %>

Write another website and deploy it at www.example.com

It will work without complicated and error-prone URL rewriting logic

baxter
  • 42
  • 2
  • Thank you.I already have this solution but I want to do by using single domain means I don't want to create any sub domain then is possible or not. – anuj.rohila94 Jun 05 '13 at 03:49
0

Create one CS Class let say "MainClassName" and write code as below in cs file

public class MainClassName
 {
   public static void SubClassName(RouteCollection routes)
       {
        routes.MapPageRoute(
         "RouteName",      // Route name
         "{name}-{some extentions}.aspx",      // Route URL (subdomain-example.aspx)
         "~/home.aspx",// Web page to handle route
        );
       }
  }

please write below code in globle.asmx page

void Application_Start(object sender, EventArgs e)
{
    MainClassName.SubClassName(RouteTable.Routes);
}

when you will use subdomain-example.aspx this url then, it will redirect to home.aspx?name=SubDomain

Jenit
  • 1
  • 3