问题ASP.Net URL路由-我第二次重定向的路由不正确
我在ASP.NETURL路由中面临一个问题。以下是Global.asax代码:问题ASP.Net URL路由-我第二次重定向的路由不正确,asp.net,Asp.net,我在ASP.NETURL路由中面临一个问题。以下是Global.asax代码: public static void RegisterRoutes(RouteCollection routeCollection) { routeCollection.MapPageRoute("Project", "{dealname}/{city}/{projectname}/{projectid}", "~/projectpage.aspx"); routeCollec
public static void RegisterRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("Project", "{dealname}/{city}/{projectname}/{projectid}", "~/projectpage.aspx");
routeCollection.MapPageRoute("Home", "home/{dealname}/{city}", "~/index1.aspx", true, new RouteValueDictionary { { "dealname", "property-for-sale" }, { "city", "Ahmedabad" } });
routeCollection.MapPageRoute("ProjectType", "result/{dealtype}/{searchstring}", "~/result.aspx");
}
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
当我打开网址的网站路线“家”是完美的工作。但是,当使用Response.Redirect重定向到路由“ProjectType”时,前一个URL的“home/”部分作为结果保留在同一页上,并在URL中显示/home/result/{dealtype}/{searchstring},而不是/result/{dealtype}/{searchstring}
请告诉我缺少什么,或者应该做什么来解决这个问题
谢谢,
我找到了解决办法。不要使用Response.Redirect(),而是使用Response.RedirectToRoute()。此函数在实现URL路由时专门使用 参考链接: 谢谢, 穆哈尔