URL Rerouting does not appear to work in SiteFinity Version

Posted by Community Admin on 04-Aug-2018 22:40

URL Rerouting does not appear to work in SiteFinity Version 4.3.1885.0

All Replies

Posted by Community Admin on 21-Jan-2012 00:00

I am attempting to create a User Friendly URL. So the Search Engines can index more easily and our customers can refere to it easily.  So I first created a simple web form; outside the scope of the SiteFinity UI for a proof of concept.  I also did this on my localhost (which does not use SiteFinity).

the localhost (.net 4.0) worked great.
The Sitefinity Site gave me the 404 page not found error.

Both global.asax files are wired the same; Both forms are wired exactly the same.

SiteFinity?
Is this a bug or is their a work around for this issue.

URL:  http://localhost/Courses/297/CourseTitle
URL: http://www.sitefinitysampelsite.com/Courses/297/CourseTitle

I used these two sites as references about how to do this:
http://msdn.microsoft.com/en-us/library/cc668201.aspx
http://weblogs.asp.net/jalpeshpvadgama/archive/2011/12/11/easy-url-rewriting-in-asp-net-4-0-web-forms.aspx


Here is my Code Sample>  OF COURSE IN a production environment I would use a SiteFinity
Page with a Custom Control inserted into the page using the UI.

//GLOBAL.ASAX file
    void Application_Start(object sender, EventArgs e)
    
        // Code that runs on application startup
        RegisterSafetyCouncilRoutes(System.Web.Routing.RouteTable.Routes);
    
    public static void RegisterSafetyCouncilRoutes(System.Web.Routing.RouteCollection reqRouteCollection)
    
        reqRouteCollection.MapPageRoute("RouteForCourses", "Courses/CourseId/CourseName", "~/TestPageNew.aspx");
     
 
//TestPageNew.aspx
    protected void Page_Load(object sender, EventArgs e)
    
        ProcessMyPageRequest();
    
 
    private void ProcessMyPageRequest()
    
        lblTroubleShooting.Text = "";
        try
        
            string locCrsId = "";
            string locCrsName = "";
            locCrsId = Page.RouteData.Values["CourseId"].ToString();
            locCrsName = Page.RouteData.Values["CourseName"].ToString();
            lblTroubleShooting.Text += "<h1>Training Course Details page</h1>";
            lblTroubleShooting.Text  += string.Format("Displaying information for course ID : 0", locCrsId);
            lblTroubleShooting.Text  +="<br/><br/>";
            lblTroubleShooting.Text  +=string.Format("Displaying information for course Name : 0", locCrsName);
        
        catch (Exception ex)
        
            string locException = ex.ToString();
            lblTroubleShooting.Text  +="<br/>Exception Occurred: Requested Course Names could not be found<br/>";
        
    

Thanks,
Doug Lubey of Louisiana

To note: I did find a url which on the forums which spoke about this; but it appeared outdated.  http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/394951-url-rerouting.aspx

Search Engine Tags:
Url Re Route
Telerik SiteFinity CMS ReRouting ReWriting
How to change querystrings into nice urls and uri

Posted by Community Admin on 21-Jan-2012 00:00

OK...Yes it does work with a slight modification to my original global.asax code: 
Found the little bit of magic at this URL.
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/httphandler-not-working.aspx

which pointed me in the correct direction.

//Modified the Global.asax file as shown
    void Application_Start(object sender, EventArgs e)
    
        // Code that runs on application startup
        //RegisterSafetyCouncilRoutes(System.Web.Routing.RouteTable.Routes);
        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized +=
        new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
    
 
    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
    
        if (args.CommandName == "RegisterRoutes")
        
            System.Web.Routing.RouteCollection locRouteCollection = System.Web.Routing.RouteTable.Routes;
            locRouteCollection.MapPageRoute("RouteForCourses", "Courses/CourseId/CourseName", "~/TestPageNew.aspx");
        
    


works like a charm !!!
Thanks Telerik

-doug lubey of louisiana

Reference:
Master/Detail webforms
URL readability
Address line user experience is better



This thread is closed