Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nate 143 posts 184 karma points
    Jun 20, 2011 @ 01:29
    Nate
    1

    URL Routing in Umbraco

    I'm trying to setup webforms routing in umbraco.

    I have a content page off the route called "ride".  I'd like to change it from www.mysite.com/ride?id=12345 to www.mysite.com/ride/12345

    I've added the following to a class in the app code folder.

     

    public class Global : umbraco.Global
    {
    
        /// <summary>
        /// Code that runs on application startup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
    
        protected override void Application_Start(object sender, EventArgs e)
        {
            base.Application_Start(sender, e);
    
            RouteTable.Routes.Add("RideRoute", 
                                    new Route("ride/{RideGuid}", 
                                    new PageRouteHandler("~/ride")));
    
        }
    

     

    But that gives me a 404.

    I've also tried adding ~/ride/ to umbracoReservedUrls umbracoReservedPaths in the web.config

    Does anyone know how to get this to work?

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jun 20, 2011 @ 01:48
    Peter Dijksterhuis
    2

    Hi,

    you could use the standard urlrewriting that is part of umbraco

    Open urlrewriting from the config-folder and edit that file.

    HTH,

    Peter

  • Nate 143 posts 184 karma points
    Jun 20, 2011 @ 04:18
    Nate
    0

    How would I serve up that content then if I did do the URL rewriting?

    With URL routing, I was going to have one macro on the ride page that would get the RideGUID like this:

    Guid rideGuid = new Guid(Page.RouteData.Values["category"] as string);

    If I did URL rewriting doesn't that make it so it expects a page at http://www.mysite.com/ride/BB067C2C-2627-4383-9B16-694BA62B7CF5?

     

  • Nate 143 posts 184 karma points
    Jun 21, 2011 @ 19:36
    Nate
    0

    Bump.  Anyone have any ideas?

  • parwej ahamad 17 posts 37 karma points
    Dec 29, 2011 @ 15:40
    parwej ahamad
    0

    Hi Nate,

    I am also a web form developer and used 4.0 webfrom routing feature. I recently started a project on umbraco so just wondering, is there possibilities to implementing webform routing as you raised question?

    Please reply me.

    Thanks,

    Parwej

  • Nate 143 posts 184 karma points
    Dec 29, 2011 @ 21:46
    Nate
    1

    I did it through URL Rewrite that's provided by umbraco in the UrlRewriting.config file

     

    <add name="CyclingRides"
                    virtualUrl="^~/cycling/rides/(?&lt;RIDE_ID&gt;[0-9]+)$"
                    destinationUrl="~/cycling/rides?id=${RIDE_ID}"
                    ignoreCase="true" rewrite="Application" />

     

    That changes /cycling/rides?1234 to /cycling/rides/1234.  I also have acecss to ID through request.querystring on my page.  Works great!

  • parwej ahamad 17 posts 37 karma points
    Dec 30, 2011 @ 06:49
    parwej ahamad
    0

    Thanks Nate, I will follow your suggestion and it looks great.

    Someone has posted an article to work around the asp.net routing features, I didn't got a chance look into more. Soon I will you updated here if works for me.

    http://wishfulcode.com/2010/09/19/asp-net-routing-and-virtual-article-based-extensionless-website-urls/

    Thanks,

    Parwej

  • Sher 42 posts 62 karma points
    Apr 03, 2012 @ 07:32
    Sher
    0

    Hi,

    I know it is an old topic, but i cant seem to find UrlRewriting.config file in my porject, i am using Umbraco 5.0.1 CMS Web Application

    from codeplex site,

    Thanks in Advance,

    Sher

Please Sign in or register to post replies

Write your reply to:

Draft