ASP.NET URL Routing with WebForms - Using the SiteMap

非 Y 不嫁゛ 提交于 2019-12-31 03:08:26

问题


I'm trying to use Url Routing within my existing ASP.NET WebForms site. Thanks to: this link, I got it working. Now I'm trying to use a SiteMap along with my routing.

I have a page MyReport.aspx. It is in the SiteMap and accessing the page directly, works fine. I've added a route for /report/{param1}/{param2}. I was hoping the sitemap would resolve the route path (MyReport.aspx) instead of /report/{param1}/{param2}, but no dice.

I have seen examples of using the SiteMap with MVC, but this makes assumptions about having controllers and such, none of which exist with a standard webform.

The approach I'm trying now is to retrieve the actual page within a custom SiteMapProvider, but I'm not seeing a way to do this. Is there a way to get the actual ASPX page instead of the Url from the HttpContext?

Thanks, -Damien


回答1:


Damien - I recently posted a sample that might be useful. Googling "asp.net routing sitemap" should get you there (only just joined SO so can't post link yet).

Fyi you can use the SiteMap.SiteMapResolve event instead of creating a custom SiteMapProvider (for simple scenarios at least).

Hope it helps!



来源:https://stackoverflow.com/questions/841624/asp-net-url-routing-with-webforms-using-the-sitemap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!