如何路由我们的asp.net网址? [关闭]

问题描述 投票:-2回答:1

我的网址是PrintProductInvoice.aspx?id = 39&n =我想要将我们的网址路由为PrintProduct / abc。我是按数据库获取的。

如何更改您的网址。

c# jquery asp.net .net visual-studio
1个回答
0
投票

从您的问题来看,我认为您希望能够生成不依赖于物理文件名的URL模式。

这可以通过使用ASP.NET路由来实现。

这是你的路线配置或多或少的样子:

void RegisterRoutes(RouteCollection routes)
{
     routes.MapPageRoute("PrintRoute",
        "PrintProduct/{product}",
        "~/PrintProductInvoice.aspx");
}

你可以称之为:'http://youraddress.com/PrintProduct/abc'

为了配置您的路线,您需要在项目中进行一些最小的设置工作,如文章here中所述。

© www.soinside.com 2019 - 2024. All rights reserved.