我一直使用友好的网址,这是我在 Web 表单项目中所做的:
全球阿萨克斯
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("About", "About", "~/About.aspx", true);
routes.MapPageRoute("Add User", "Add User", "~/Add.aspx", true);
routes.MapPageRoute("Login", "Login", "~/Login.aspx", true);
routes.MapPageRoute("Map", "Map", "~/Map.aspx", true);
routes.MapPageRoute("Register", "Register", "~/Register.aspx", true);
routes.MapPageRoute(
"ViewList",
"ViewList/{c}/{s}",
"~/ViewList.aspx",
true
);
routes.MapPageRoute(
"ViewUser",
"ViewUser/{id}",
"~/ViewUser.aspx",
true
);
routes.MapPageRoute(
"MyAccount",
"MyAccount/{id}",
"~/MyAccount.aspx",
true
);
}
页面接收查询字符串
string city = RouteData.Values["c"].ToString();
string state = RouteData.Values["s"].ToString();
您不需要在此配置中拆分查询字符串值。