如果你将虚拟ur改到物理档案中,那么在全球这样做非常容易。 页: 1
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
RouteTable.Routes.MapPageRoute("Key", "Home", "~/Public/Pages/Default.aspx");
}
在这种情况下,
http://www.example.com/Home
改头
Just an FYI, doing this doesn t redirect on the client, it redirects on the server, meaning that the server doesn t return a 302 with the new address, it simply sends back the content you re directing it to.
这对增加变量也至关重要,例如:
routes.MapPageRoute("MainPublic3", "Public/Pages/{PAGE}/{CHILD}", "~/Public/Pages/Pages.aspx");
These can then be accessed in the code behind like this:
string page = Page.RouteData.Values["PAGE"];
string child = Page.RouteData.Values["CHILD"];
We use this for everything where I work, of course we are switching to MVC :)