RouteTable.Routes.Addstructurewas able to usein
asp.net
webforms.
but,
the error
iswithinwebpages.only
works
with
the folder
structure of
the routing
andcshtmlurl?How can I usethe followingstructure?
RouteTable.Routes.Add("cat", new Route("category/{catname}-{catid}", new PageRouteHandler("~/Default.cshtml")));
RouteTable.Routes.Add("search", new Route("search/{src}", new PageRouteHandler("~/Default.cshtml")));
PageRouteHandler is specifically designed for WebForms - it tries to create System.Web.UI.Page types - which would fail spectacularly when it tries to do that on a cshtml/vbhtml page. My NuGet package corrects that by creating a route handler that can serve
Asp.Net WebPages web pages (:D). It's not so much a third party solution as a file sitting in App_Code.
aspnet1071
Member
64 Points
35 Posts
RouteTable.Routes.Add
Jul 07, 2011 02:00 PM|LINK
RouteTable.Routes.Add structure was able to use in asp.net webforms. but, the error is within webpages. only works with the folder structure of the routing and cshtml url? How can I use the following structure?
RouteTable.Routes.Add("cat", new Route("category/{catname}-{catid}", new PageRouteHandler("~/Default.cshtml"))); RouteTable.Routes.Add("search", new Route("search/{src}", new PageRouteHandler("~/Default.cshtml")));Mikesdotnett...
All-Star
154951 Points
19870 Posts
Moderator
MVP
Re: RouteTable.Routes.Add
Jul 07, 2011 03:08 PM|LINK
Have a look at pranavkm's Web Pages Routehandler:
http://forums.asp.net/t/1681742.aspx/1?URL+Routing+am+I+missing+something+
http://forums.asp.net/t/1676186.aspx/2/10?Extension+less+URL+s+with+Querystrings+
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
aspnet1071
Member
64 Points
35 Posts
Re: RouteTable.Routes.Add
Jul 07, 2011 03:24 PM|LINK
I do not want three.party component, does not have a solution in webpages?
pranavkm
Participant
796 Points
106 Posts
Re: RouteTable.Routes.Add
Jul 07, 2011 03:42 PM|LINK
PageRouteHandler is specifically designed for WebForms - it tries to create System.Web.UI.Page types - which would fail spectacularly when it tries to do that on a cshtml/vbhtml page. My NuGet package corrects that by creating a route handler that can serve Asp.Net WebPages web pages (:D). It's not so much a third party solution as a file sitting in App_Code.
Mikesdotnett...
All-Star
154951 Points
19870 Posts
Moderator
MVP
Re: RouteTable.Routes.Add
Jul 07, 2011 04:26 PM|LINK
Copy and paste the code from the second link. Call it yours. I'm sure pranavkm won't mind so long as it solves your issue.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter