asp.net c# url

Ibrar Tariq 20 Reputation points
2024-01-13T19:10:45.24+00:00

I am using asp.net c# and xml file and want to create url like as given below example: this one original url

~/products/product123.aspx

and open to

~/products123.aspx

when the user click the hyperlink open the ~/products123.aspx instead of original like as YouTube remember that the original url save in xml file. Please solve my problem Thanks

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,592 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 30,176 Reputation points Microsoft Vendor
    2024-01-15T10:04:43.2+00:00

    Hi @Ibrar Tariq,

    You can choose the method based on your needs: IIS URL rewriting and ASP.NET routing.

    Which Option Should You Use?

    In a Web Forms application, you create routes by using the MapPageRoute(String, String, String) method of the RouteCollection class. The MapPageRoute method creates a Route object and adds it to the RouteCollection object. You specify properties for the Route object in parameters that you pass to the MapPageRoute method.

    RouteConfig

     public static void RegisterRoutes(RouteCollection routes)
     {
         routes.MapPageRoute("products", "products123.aspx", "~/products/product123.aspx");
     }
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,101 Reputation points
    2024-01-13T21:39:27.0466667+00:00

    There are a couple approaches. The first is to create rewrite rules in iis. You can also create dummy pages that redirect.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.