开发者

GetRouteUrl returns null and RedirectToRoute throws "No matching route found for RedirectToRoute."

开发者 https://www.devze.com 2022-12-31 19:34 出处:网络
Page.GetRouteUrl(\"routename\", new { blah = \"blah\" }) Returns null Response.RedirectToRoute(\"routename\", new { blah = \"blah\" })
Page.GetRouteUrl("routename", new { blah = "blah" })

Returns null

Response.RedirectToRoute("routename", new { blah = "blah" })

throws InvalidOperationException("No matching route found for Redirec开发者_StackOverflow中文版tToRoute.")

I put a breakpoint and checked System.Web.Routing.RouteTable.Routes and my routes are there. I can use them without a hitch in my page code. What's the deal?


Check your route restrictions. I ran into the same problem before and it turned out that my route restrictions were incorrect.

Hope that helsps


Try:

Response.Redirect(string.Format("~/Blah.aspx/{0}", blah.ToString()));

Instead of:

Response.RedirectToRoute("routename", new { blah = "blah" }) 
0

精彩评论

暂无评论...
验证码 换一张
取 消