简体   繁体   中英

Url mapping in asp.net

I want to do url mapping using coding in asp.net c#

if /default.aspx page is requested then on client site it should be shown /default. asp.net(c#) 4.0 .net framework

From Scott Guthrie Article

Mapping URLs using ASP.NET Web Forms

ASP.NET 4.0 now allows you to also use the URL Routing engine to map URLs to ASP.NET Web Forms pages as well as ASP.NET MVC Controllers.

Below is an example of how you can use the new MapPageRoute() helper method in ASP.NET 4.0 to map the /default URL to a default.aspx page that lives immediately under the application root directory:

void RegisterRoutes(RouteCollection routes)
{

    routes.MapPageRoute(
    "default-page",
    "default",
    "~default.aspx"
    );
}
void Application_Start()
{
    RegisterRoutes(RouteTable.Routes);
}

You may like to check this Url Rewriting with ASP.NET and Managed Fusion URL Rewriter and Reverse Proxy . Also check this example:- An Example of URL Rewriting With ASP.NET

Also check out the Microsoft.AspNet.FriendlyUrls to easily use routing and get friendly urls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM