开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜