Question

I feel like this should be easy, but I'm struggling. I'd like a user to be able to go to this url:

http://www.mysite.com/folder/some-id-text

and have URL Rewrite direct that request here:

http://www.mysite.com/folder/index.aspx?id=some-id-text

http://www.mysite.com/folder/some-id-text should be the only url the user ever sees.

Was it helpful?

Solution

in your project edit Global.asax file and add the code below.

 protected void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(System.Web.Routing.RouteTable.Routes);
    }

    public static void RegisterRoutes(System.Web.Routing.RouteCollection routes)
    {

        routes.MapPageRoute("somename",
            "folder/{text-id}",
            "~/index.aspx");
    }

then in your index.aspx you can find this variable as

 string text_id = RouteData.Values["text-id"].ToString();

further ref http://code.msdn.microsoft.com/Easy-Steps-to-URL-2f792901

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top