Asp.net C.NET4.0中的URL重写
以下是我在globle.asax.cs文件中的代码:Asp.net C.NET4.0中的URL重写,asp.net,c#-4.0,url-rewriting,url-routing,Asp.net,C# 4.0,Url Rewriting,Url Routing,以下是我在globle.asax.cs文件中的代码: public static void RegisterRoutes(RouteCollection routeCollection) { routeCollection.MapPageRoute("Account", "home", "~/Default.aspx"); routeCollection.MapPageRoute("logout", "account", "
public static void RegisterRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("Account", "home", "~/Default.aspx");
routeCollection.MapPageRoute("logout", "account", "~/Account.aspx");
routeCollection.MapPageRoute("Doccat", "dcat/{Id}", "~/Documents.aspx");
}
这适用于前两个路由,并提供以下URL:
http://localhost.com/about
最后一个URL提供了我的自定义类别ID:
到目前为止还不错,但当我http://localhost.com/dcat/1 这个URL将/dcat作为一个文件夹,所有链接都位于该网站的目录中。例如
更改为
这会影响站点中图像、css和所有内容的所有路径
请任何人在这方面帮助我,这太麻烦了。你能显示其中一个链接的代码吗?谢谢你的问题@ChrisGessler,我的Default.aspx和Account.aspx页面上没有代码,Documents.aspx页面上只有一行,如下所示:string id=page.RouteData.Values[id].ToString;