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?

1

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.