+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Extensionless URLs in Sitefinity 3.6

Extensionless URLs in Sitefinity 3.6

44 posts, 0 answered
  1. David
    David avatar
    26 posts
    Registered:
    12 Jul 2008
    06 Apr 2009
    Link to this post
    Hi,

    I am using the latest version of Sitefinity (3.6.1870). According to this post (http://blogs.sitefinity.com/Ivan/Posts/09-02-12/Sitefinity_3_6_released.aspx) there are now extensionless URLs.

    How do I use extensionless URLs? The documentation (http://www.sitefinity.com/support/documentation.aspx) is still for 3.5.

    I have a site that is made up of microsites and want to create URLs like these:
    http://www.mysite.com/
    http://www.mysite.com/site1/
    http://www.mysite.com/site2/

    I do not want each microsite landing page to have a filename. So this is wrong:
    http://www.mysite.com/default.html

    I have amended:
    <cms defaultProvider="Sitefinity" pageExtension=".aspx"
    to be:
    <cms defaultProvider="Sitefinity" pageExtension=".html"

    Thanks
    Dave Cooper
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Apr 2009
    Link to this post
    Hello David,

    This part of the documentation is not changed, but it applies for version 3.6 as well.

    Basically you need to take the following steps:

    1. Set the customErrors properties in the web.config file like:
          <customErrors mode="On"
              <error redirect="~/Sitefinity/nopermissions.aspx" statusCode="403" /> 
          <error redirect="~/sf404.aspx" statusCode="404" /> 
          </customErrors> 

    Sf404.aspx is an internal Sitefinity page. If I should be honest, it is not even a page, but Sitefinity is handling the requests having sf404.aspx, and knowns that the user want to use extensionless urls.

    You can do the same in IIS, instead of the web.config file.

    2. You will now notice that you can perform requests as the following:
    http://site.com/page1
    http://site.com/group/pagex

    3. If you want your Sitemap links to be generated without extension as well, you should set the pageExtension property to empty string:
    <cms defaultProvider="Sitefinity" pageExtension="" .. 

    Give a try to this approach, and let me know if this is the behavior you expect.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. David
    David avatar
    26 posts
    Registered:
    12 Jul 2008
    06 Apr 2009
    Link to this post
    Thanks for the reply.

    The behaviour is not quite right. The issues I have are:

    1. The home page redirects from "/" to "/default.html"

    2. The pages do not work correctly if the URL ends in a slash. I have seen a post that gives a solution to this but even with this solution the CSS file added as part of the theme have the wrong path so the page looks wrong.

    Any help is appreciated.

    Thanks
    Dave Cooper
  4. Adam @Habanero
    Adam @Habanero avatar
    45 posts
    Registered:
    22 Jun 2012
    06 Apr 2009
    Link to this post
    If we change the cutom errors 404 to redirect to sf404.aspx, can we still somehow wire up a custom error page?
  5. David
    David avatar
    26 posts
    Registered:
    12 Jul 2008
    07 Apr 2009
    Link to this post
    Hi,

    I have continued to look into URL rewriting with Sitefinity and although I have a lot of respect for how Sitefinity does a lot of things, I must say that the URL rewriting aspects are not good at all. I can report the following bugs:

    1. When changing the pageExtension attribute in the web.config, the cms will break with the error message "telerik.cms is undefined"

    2. Also after making the above change the homepage of the site can no longer be accessed using "/" but needs to be "/home.html"

    3. When extensionless URLs are used the stylesheets added in by .NET from the themes folder no longer work. The URL to them are now wrong so extensionless URL rewriting is useless.

    The only thing I need to fix is number 3, the aspx to html thing I can do custom rewriting. I think that what needs doing is that Sitefinity is now handling the rewriting of the URLs that end in / but you need to use the RewritePath overload as described here: http://msdn.microsoft.com/en-gb/1kz7fdx9.aspx so that the path to the theme css is not broken.

    Thanks
  6. David
    David avatar
    26 posts
    Registered:
    12 Jul 2008
    07 Apr 2009
    Link to this post
    Since the elegant solution to this problem is not possible since the code I need to change is compiled away, I have written a work-around that is not great but it works:

    protected override void Render(HtmlTextWriter writer)
        {
            if (Request.RawUrl.EndsWith("/"))
            {
                RecurseControls(Page.Controls);
            }

            base.Render(writer);
        }

        private static void RecurseControls(ControlCollection controls)
        {
            foreach (Control control in controls)
            {
                HyperLink anchor = control as HyperLink;

                if ((anchor != null) && anchor.NavigateUrl.StartsWith("~/"))
                {
                    anchor.NavigateUrl = anchor.NavigateUrl.Substring(1);
                }
                else
                {
                    HtmlLink link = control as HtmlLink;

                    if ((link != null) && link.Href.StartsWith("~/App_Theme"))
                    {
                        link.Href = link.Href.Substring(1);
                    }
                }

                RecurseControls(control.Controls);
            }
        }

    Thanks
    Dave Cooper
  7. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    07 Apr 2009
    Link to this post
    Hey Dave,

    Thanks so much for your contributions to this thread!  I've been interested in the extensionless URLs topic for awhile.

    Georgi, I tried using an empty string for the pageExtension property:

    <cms defaultProvider="Sitefinity" pageExtension="" ...

    In my example, this broke the entire web site.  All web pages return the following error:

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /standard-3.6/sf404.aspx


    I'm probably doing something wrong, but I've had no luck with this.  Thoughts?

    Gabe Sumner
    http://www.sitefinitywatch.com/
  8. Nikolai
    Nikolai avatar
    216 posts
    Registered:
    21 Nov 2016
    08 Apr 2009
    Link to this post
    Hello,

    Could you please try this:
    1. Leave this <cms defaultProvider="Sitefinity" pageExtension="" as it is.
    2. Open IIS and map a custom error page for the 404 error handling like this /[YourProjectName]/sf404.aspx

    By taking these steps, you will be able to use extensionless URLs. Your links will be generated without extensions as well.

    Sincerely yours,
    Nikolai
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  9. Mark
    Mark avatar
    8 posts
    Registered:
    23 Jan 2009
    27 Jun 2009
    Link to this post
    Hello,

    I would like to use extensionless URL and I have set pageExtension="" in the web.config.

    Now if I try to create a new page or edit an existing one I am redirected to the login page, even though I am logged in already. If I try to log in again I am still redirected to the login page.

    Have you heard of this and can you suggest a reason/solution?

    Regards,
    Mark.
  10. Vlad
    Vlad avatar
    498 posts
    Registered:
    15 Jul 2016
    30 Jun 2009
    Link to this post
    Hi Mark,

    The problem is that FormsAthentication and RoleManager modules are not available for extensionless requests. You can find more details here:
    ASP.NET Integration With IIS 7.0

    You could to fix this issue by setting runAllManagedModulesForAllRequests attribute of the system.webServer -> modules element to true in the web.config:

      <system.webServer> 
        <modules runAllManagedModulesForAllRequests="true"

    Or, you can add the modules manually without precondition:
      <system.webServer> 
        <validation validateIntegratedModeConfiguration="false"/> 
        <modules
          <remove name="FormsAuthentication"/> 
          <remove name="RoleManager"/> 
          <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" /> 
          <add name="RoleManager" type="System.Web.Security.RoleManagerModule" /> 
     

    Hope this is helpful.

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Mark
    Mark avatar
    8 posts
    Registered:
    23 Jan 2009
    30 Jun 2009
    Link to this post
    That worked. Thanks.
    Mark.
  12. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    08 Dec 2009
    Link to this post
    I'm not happy with this functionality so far (in 3.7). I've set up the sf404.aspx workaround and it doesn't quite do what I want. The URL the browser gets is a redirect URL starting with sf404.aspx. That's just a cosmetic issue, but I'm finding that actual "missing" pages come up blank - no 404 error.

    What I expected to be able to do was set up a page group that would lead to a default page. So I set up a page group called "InfoTours". I set up a sub page "default.aspx". Sitefinity tells me that the page can be accessed at ~/InfoTours/default.aspx. I have IIS set so default.aspx is the default document for the whole site.

    So currently I can get to this page in the following ways:

    ~/InfoTours.aspx
    ~/InfoTours/default.aspx

    What I can't do, that I NEED to do is get to it through:

    ~/InfoTours/

    All of our published URLs are in this format.

    I would like Page Groups to be extensionless, and only Page Groups. Or I would like the application to honor the IIS default document. Or I would like sf404.aspx to allow proper 404 errors (and custom errors as well) when appropriate. Or some better mechanism for extensionless URLs in general. In any case, I need this functionality before I can use the product (which we have purchased a license for). Thanks!


  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 Dec 2009
    Link to this post
    Hello Richard,

    Unfortunately the Extensionless urls could not be limitted to the page groups only. This is a core functionality and could not be changed that easy, but we will definitely put it under question, and perhaps extend it to meet these requirements. 

    By the way, when you append an additional slash (/) at the end, the Url path is changed, at least this is the case by the specifications.

    Which version of 3.7 are you running on?


    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    10 Dec 2009
    Link to this post
    I am running 3.7 SP2.

    Please address the rest of my question: 
    Or I would like the application to honor the IIS default document. Or I would like sf404.aspx to allow proper 404 errors (and custom errors as well) when appropriate.

    The current mechanism for extensionless URLs is not working for me. Is sf404.aspx supposed to return a blank page when the page is not found? It does for me. This makes it unusable.




  15. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    11 Dec 2009
    Link to this post
    Hi Richard,

    As I mentioned in the previous post, this is the current implementation, it is root implementation and could not be changed easily. What we can do though is to evaluate it again and possibly change it in out future 3.x versions.

    Have you tried to use wildcard mappings, to map all request to Asp.Net?


    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  16. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    11 Dec 2009
    Link to this post
    Thank you for your reply. Wildcard URLs aren't practical as over half my content is old asp pages. sf404.aspx is broken as it returns blank pages for actual 404 errors. This is a serious bug. It appears to me that these are issues that you promised to fix back in 2007 in this thread:
    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/extensionless-urls.aspx

    I'm sorry but I need this to work now. sf404.aspx must return 404 errors when it is appropriate or (better) redirect to another error page. Since it returns blank pages I would consider that a bug that needs to be fixed rather than a feature request.

    I have licensed this product and am trying to move my main Web site to it. Without properly functioning extensionless URLs that can't happen. This is a really common, basic requirement for many sites. Nobody who implements a CMS wants to have to change all of their URLs, particularly when they are published in articles, on business cards, etc. Please allocate the necessary resources and resolve this issue.


  17. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Dec 2009
    Link to this post
    Hello Richard,

    The sf404 approach works in Classic pipe line mode, but not in integrated mode. The integrated mode works in a very different way, and has wildcard mappings mapped by default - due to the integration between the ASP.NET runtime and IIS, the default integrated pipeline mode handles all requests through a unified pipeline. I am sure there is a way to run both old asp code and to have the rest of the requests mapped to asp.net. 

    The questions is, are you running the application in Integrated Pipeline mode? if this is the case, then sf404 is not used at all. 

    When I use the sf404 approach in a local project (running on IIS7.5, Windows 7), here is what I do:

    1. Set the pageExtension to empty string in the web.config file - ""
    2. Do not add an entry in the web.config in the <customErrors.. section
    3. Set the 404 error page in IIS to Execute the following path /37sp2/sf404.aspx 
    4. Swith to Classic mode 

    If I request a page which does not exist, I get a 404 not found error (coming from Asp.Net, not from IIS!).

    Please let me know about your web.config and IIS settings, as well as if you are running in Classic or Integrated pipeline mode. 

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  18. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    14 Dec 2009
    Link to this post
    Georgi,

    Thanks for your reply.

    The application is running in Classic mode. However, the thread from 2007 referred to a problem when the site was running as the root directory rather than a virtual directory.That is the way my site is configured. IIS is configured with the physical path for the site pointing at the Sitefinity project directory and for the 404 error to go to /sf404.aspx. The extensionless URLs work in this configuration but no error is returned for legitimate 404 errors.

    If you create a site where the Sitefinity project is the root directory rather than a virtual directory do you still get normal 404 errors?
  19. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    15 Dec 2009
    Link to this post
    Hello Richard,

    I have tested with with a root site as well, but everything is fine. I have attached screenshots for you of all settings that I have done. 

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  20. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    15 Dec 2009
    Link to this post
    Georgi,

    This is interesting. I still have the same issue, with the same settings as yours. On two different servers. I have done a packet trace and found that the web server is returning a 404 error that has no content, so the page is blank.

    I will submit a support ticket.

  21. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Dec 2009
    Link to this post
    Hi Richard,

    All right, let's escalate this to a support ticket. We will follow up there. 

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  22. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    17 Dec 2009
    Link to this post
    This work did not seem to help the issue we have of people requesting the "folder" and not getting anything. I am looking for a way to handle users who are requesting www.mysite.com/jobs (which is a folder) to be taken to www.mysite.com/jobs/default.aspx

    There are ways to handle this in code with a handler:

    http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    or I could handle it in IIS 7 with an extension:

    http://www.iis.net/expand/URLRewrite

    I would like to avoid that though if I can handle it at the Site Finity level.
  23. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Dec 2009
    Link to this post
    Hello,
    I suggest you trying the following:

    You should be working in integrated mode. Set the custom errors showed just like on my screenshot (attached to this post). Create a directory named test, and place a default.htm file inside containing some text. Make sure that the pageExtension property is set to empty string in the web.config file. 

    Now, browse a page from the sitemap, without the extension. You should be able to see it. Try to browse http://localhost/test - you should be able to see the default.htm file contents as well. 

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  24. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    18 Dec 2009
    Link to this post
    Georgi,

    Thanks, that works - except that the detailed errors are more information than I would like to send to users. One of the reasons for going extensionless is to hide the implementation details of the server. The detailed errors give a LOT of information including the physical paths of the files.
  25. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Dec 2009
    Link to this post
    I must be entirely out of my depth here since I don't know much about IIS's way of handling requests and mapping, but browsing to a directory rather than a page seems to me to be a fundamental requirement for any website albeit CMS or not.

    For an entertainment company you would absolutely want to be able to promote the URL 
    www.MyEntertainmentCompany.com/movies or 
    www.MyEntertainmentCompany.com/games or
    www.MyEntertainmentCompany.com/books

    I don't understand where 404 error pages fits into this at all? Sitefinity's motto is that it's very easy for developers to extend, but this seems highly complicated and most certainly unnecessary for a feature that is so commonly used. 

    Regards,
    Jacques

  26. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Dec 2009
    Link to this post
    Hello J.Hov,

    Well, it was really hard to have extensionless urls and directory handling in IIS 5/6 and classic pipe line mode. If you dig into the request and their execution path, you will see what I mean. Considering the fact that all pages and sub pages are not physical ones, the 404 error makes perfect sense - you should teach your application how to handle it. Instead of writing this from scratch, we are providing it and its ready to use. 

    Try to write an application for classic mode, with dynamic pages saved in database, and try to handle extensionless urls having in mind directories. Needless to say, we would be glad if you could share your experience - perhaps there is a better way of handling this scenario. 

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  27. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    19 Dec 2009
    Link to this post
    Hi Georgi,

    Thanks for your comments. 

    1. Does what you say apply to the IIS standard method of dealing with 'default' files where http://www.mysite.com/movies/ is redirected to http://www.mysite.com/movies/default.aspx? 

    2. When you say it's difficult to achive does this mean it's something that is going to take a long time to bring into the 'easily configurable' feature set of Sitefinity? 

    Regards,
    Jacques
  28. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Dec 2009
    Link to this post
    Hello J.Hov,

    The answer is Yes, to both questions. This is only valid for IIS5/6 and IIS7 in Classic pipeline mode. IIS7 Integrated mode is different story - the 404 errors are not used at all to handle the files and directories correctly.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  29. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    19 Dec 2009
    Link to this post
    It appears to me that Sitefinity's extensionless functionality is similar to what's described in this article:

    http://www.codeproject.com/KB/aspnet/extensionless.aspx

    Particularly when I look at the following code. I do get proper 404 errors IF the URL contains a period. Otherwise I get a page with a 404 error header but no content (blank page). Of course the whole point of extensionless URLs is that there are no extensions, so this approach seems questionable to me:

      31:             if( requestedFile.IndexOf('.') > 0 ) 
      32:             { 
      33:                 // There's some extension, so this is not an extensionless URL. 
      34:                 // Don't handle such URL because these are really missing files 
      35:             } 

    I need to get this site running, so for now I'm using the IIS URL Rewrite module, which works OK (download from iis.net). I got the rules from one of your competitors in the link below (sorry). Apparently their built-in extensionless URLs are also based on 404 errors and they have some issues too, so they provided this alternative:

    http://blog.keithpatton.com/2009/04/18/IIS7+Extensionless+Urls+And+Kentico+CMS+40.aspx

    One advantage of the URL Rewrite module is that I can use my own custom errors, which the sf404.aspx solution doesn't seem to allow.

  30. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    21 Dec 2009
    Link to this post
    When I originally posted above I was going to suggest using the URL Rewrite module or the rewrite module metioned in the Scott Guthries' ASP.NET blog. I am going to use the URL Rewrite module as I would prefer my server handle this and not my code if I can get away with it. Let me know how it works for you.
Register for webinar
44 posts, 0 answered
1 2