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

Forums / Developing with Sitefinity / Url Rewriting with 3rd party dll (UrlRewriter.net)

Url Rewriting with 3rd party dll (UrlRewriter.net)

10 posts, 0 answered
  1. Matthew Snyder
    Matthew Snyder avatar
    15 posts
    Registered:
    21 Sep 2009
    16 Dec 2010
    Link to this post
    Hello,

    I just configured UrlRewriter.net in my website project using vs2k8 and iis7. UrlRewriter.net is a third party dll that helps manage url rewriting, similar to the Sitefinity module. I am able to successfully use UrlRewriter.net, but only on physical pages that exist in my project. 

    Something like this works because WebForm1.aspx is a real file in my web project:
    <rewrite url="/TestPage.aspx" to="~/WebForm1.aspx" />

    This does not work and produces a 404 error:
    <rewrite url="/TestPage.aspx" to="~/AnySitefinityCreatedPage.aspx" />

    I have done all of my testing locally (using the http://localhost url), and have only modified the web.config file as per UrlRewriter.net's instructions.

    Can you provide me with help to allow UrlRewriter.net to recognize my Sitefinity-created pages?

    Thanks.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Dec 2010
    Link to this post
    Hello Matthew,

    We have not tested the url rewriting component that  you use and we are not familiar with its engine. All content urls and page urls created by Sitefinity are rewritten. Pages and content items are dynamically created and this could be one of the reasons for the behavior you see.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Matthew Snyder
    Matthew Snyder avatar
    15 posts
    Registered:
    21 Sep 2009
    27 Dec 2010
    Link to this post
    Ivan, thanks for your reply. I have some updates:

    I am not using this third party app anymore, rather, I have switched to the IIS URL Rewrite (http://www.iis.net/download/urlrewrite). Certain features of this, such as enforcing lower-case urls, removing trailing slashes, etc, work well on our site, but I am still having problems with the dynamically created Sitefinity pages. As a test case, I created a "Test.aspx" page within the website project and tried to use the "Friendly Url" feature, which worked. I was able to create a rule that redirected ".../Test.aspx?Id=1" to ".../Test/1.aspx". Then, I tried an identical scenario on a .aspx page that Sitefinity creates and received a 404 error. Here is the code that the Url Rewrite tool generates for my web.config file, with TitleDetails.aspx being the Sitefinity created page:

    <rewrite>
        <rules>
            <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                <match url="^bookstore/titledetails\.aspx$" />
                <conditions>
                    <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                    <add input="{QUERY_STRING}" pattern="^TitleId=([^=&amp;]+)$" />
                </conditions>
                <action type="Redirect" url="bookstore/titledetails/{C:1}" appendQueryString="false" />
            </rule>
            <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                <match url="^bookstore/titledetails/([^/]+)/?$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="bookstore/titledetails.aspx?TitleId={R:1}" />
            </rule>
        </rules>
        <outboundRules>
            <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Form, Img" pattern="^(.*/)bookstore/titledetails\.aspx\?TitleId=([^=&amp;]+)$" />
                <action type="Rewrite" value="{R:1}bookstore/titledetails/{R:2}/" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>
    </rewrite>

    After looking closely at several URL rewriting possibilities, including Sitefinity's URL rewriting functionality, we have chosen the IIS feature. It is very important that Sitefinity does not hinder our efforts to proceed with the IIS url rewrite feature, and I feel that they should play nicely with each other since IIS is not a third party app. Can you please help me resolve this issue? Thanks in advance.

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Dec 2010
    Link to this post
    Hi Matthew Snyder,

    Thank you for getting back to us.

    Generally there should be no problem with using the IIS UrlRewrite module with Sitefinity. You just have to make sure that the UrlRewrite module executes before the CmsHttpModule. This is required so that it can pass the rewritten path to Sitefinity and the CMS to be able to serve the actual page.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Matthew Snyder
    Matthew Snyder avatar
    15 posts
    Registered:
    21 Sep 2009
    28 Dec 2010
    Link to this post
    Thanks for the reply. I'm still having some trouble with this, though. Can you tell me how my web.config should be set up to ensure it loads before the Cms Module? Is there any other information I can provide to help with the troubleshooting process? Thanks.

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="ScriptModule" />
          <remove name="Cms" />
          <remove name="RadUploadModule" />
          <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms" />
          <add name="RadUploadModule" preCondition="managedHandler" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
        </modules>
        <handlers>
          <remove name="ScriptResource" />
          <remove name="WebServiceHandlerFactory-Integrated" />
          <remove name="ScriptHandlerFactory" />
          <remove name="ScriptHandlerFactoryAppServices" />
          <remove name="SitefinityTemplate" />
          <remove name="SitefinityThumbnail" />
          <remove name="SitefinityLibrary" />
          <remove name="RadUploadProgress" />
          <remove name="SitefinityRSS" />
          <remove name="Dialog" />
          <remove name="Spellcheck" />
          <remove name="ChartImage" />
          <remove name="CaptchaImage" />
          <remove name="Metablog" />
          <remove name="Trackback" />
          <remove name="AmazonLibrary" />
          <remove name="AmazonLibraryAdd" />
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="SitefinityTemplate" path="*.template" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
          <add name="SitefinityThumbnail" path="*.tmb" verb="*" preCondition="integratedMode" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
          <add name="SitefinityThumbnailAdd" path="*.tmb.ashx" verb="*" preCondition="integratedMode" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
          <add name="SitefinityLibrary" path="*.sflb" verb="*" preCondition="integratedMode" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
          <add name="SitefinityLibraryAdd" path="*.sflb.ashx" verb="*" preCondition="integratedMode" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
          <add name="SitefinityRSS" preCondition="integratedMode" verb="*" path="*.rss" type="Telerik.Rss.RssHttpHandler, Telerik.Rss" />
          <add name="SitefinityRSSAdd" preCondition="integratedMode" verb="*" path="*.rss.ashx" type="Telerik.Rss.RssHttpHandler, Telerik.Rss" />
          <add name="RadUploadProgress" verb="*" preCondition="integratedMode" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" />
          <add name="Dialog" preCondition="integratedMode" verb="*" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" />
          <add name="Spellcheck" preCondition="integratedMode" verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" />
          <add name="ChartImage" preCondition="integratedMode" verb="*" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI" />
          <add name="CaptchaImage" preCondition="integratedMode" verb="GET" path="CaptchaImage.axd" type="Telerik.Web.UI.SpamProtection.Captcha.CaptchaImageHandler, Telerik.Cms.Web.UI" />
          <add name="Metablog" preCondition="integratedMode" verb="POST" path="blogs/metablog.ashx" type="Telerik.Blogs.MetaWeblog.MetaWeblogHandler, Telerik.Blogs" />
          <add name="Trackback" preCondition="integratedMode" verb="POST" path="trackback.ashx" type="Telerik.Cms.Engine.Trackback.TrackbackHandler, Telerik.Cms.Engine" />
          <add name="AmazonLibrary" path="*.s3lb" verb="*" preCondition="integratedMode" type="Telerik.Libraries.AmazonStorage.S3StorageHandler, Telerik.Libraries" />
          <add name="AmazonLibraryAdd" path="*.s3lb.ashx" verb="*" preCondition="integratedMode" type="Telerik.Libraries.AmazonStorage.S3StorageHandler, Telerik.Libraries" />
          <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" />
        </handlers>
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Dec 2010
    Link to this post
    Hi Matthew Snyder,

    Open up your website in IIS and go to the Modules section. In the right hand side select the View Ordered list option and see the order of http modules for the website. The CMS module should appear in the list after the rewrite one.
     
    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Matthew Snyder
    Matthew Snyder avatar
    15 posts
    Registered:
    21 Sep 2009
    29 Dec 2010
    Link to this post
    Hello,

    The Cms module does not appear in the IIS module listing (image attached). Since the UrlRewrite module is listed in the IIS module list, but not in the web.config, and the Cms module is listed in the web.config but not the IIS module list, I suppose I will need to add one to the IIS module list and delete it from the web.config, or vice versa, but I don't know how to accomplish this. Can you please tell me how this can be done? Thanks.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    11 Jan 2011
    Link to this post
    Hello Matthew Snyder,

    I have sent a response to you to the support thread you have opened.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Adam
    Adam avatar
    8 posts
    Registered:
    25 Oct 2010
    24 Mar 2011
    Link to this post
    I am running into the same situation. However, I do not have access to the IIS settings as the posts above do. I'm running sitefinity on IIS7 on Mosso (Rackspace cloudsites).
    My error is the same.

    Sections from my web.config:
      
    <modules runAllManagedModulesForAllRequests="true">
            <remove name="ScriptModule" />
            <remove name="Cms" />
            <remove name="RadUploadModule" />
            <remove name="UrlRewriter" />
            <remove name="AccessModuleFix"/>   
     
            <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="Cms" type="Telerik.Cms.Web.CmsHttpModuleUrlRewrite, Telerik.Cms" />
            <!-- Http Module for extension mappings in Library module.-->
            <!--<add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>-->
            <add name="RadUploadModule" preCondition="managedHandler" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
            <add name="AccessModuleFix" type="Telerik.Fixes.AccessModule, App_Code"/> <!-- patch for image upload vulnerability, added 1/13/2011 -->
     
        </modules>
     
     
        <handlers>
            <remove name="ProgressHandler"  />
            <remove name="RssHttpHandler" />
            <remove name="RssHttpHandlerashx"  />
            <remove name="ContentHttpHandler"  />
            <remove name="ContentHttpHandlerashx" />
            <remove name="ContentHttpHandlertmb"  />
            <remove name="ContentHttpHandlertmbashx" />
            <remove name="DialogHandler" />
            <remove name="SpellCheckHandler"  />
            <remove name="ChartHttpHandler"/>
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryaxd"  />
            <remove name="ScriptResourceHandler" />
            <remove name="CaptchaImageHandler"/>
            <remove name="MetaWeblogHandler"/>
            <remove name="TrackbackHandler"/>
            <remove name="S3StorageHandler"/>
            <remove name="S3StorageHandlerashx"/>
            <remove name="WebResource"/>
            <remove name="Cms" />
     
     
     
            <add name="ProgressHandler" verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" />
            <add name="RssHttpHandler" verb="*" path="*.rss" type="Telerik.Rss.RssHttpHandler, Telerik.Rss" />
            <add name="RssHttpHandlerashx" verb="*" path="*.rss.ashx" type="Telerik.Rss.RssHttpHandler, Telerik.Rss" />
            <add name="ContentHttpHandler" verb="GET" path="*.sflb" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
            <add name="ContentHttpHandlerashx" verb="GET" path="*.sflb.ashx" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
            <add name="ContentHttpHandlertmb" verb="GET" path="*.tmb" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
            <add name="ContentHttpHandlertmbashx" verb="GET" path="*.tmb.ashx" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine" />
            <add name="DialogHandler" verb="*"  path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" />
            <add name="SpellCheckHandler" verb="*"  path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" />
             
            <add name="ChartHttpHandler" verb="*"  path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI" />
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryaxd" verb="*" path="*_AppService.axd"  type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptResourceHandler" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  />
            <add name="CaptchaImageHandler" verb="GET" path="CaptchaImage.axd" type="Telerik.Web.UI.SpamProtection.Captcha.CaptchaImageHandler, Telerik.Cms.Web.UI" />
            <add name="MetaWeblogHandler" verb="POST" path="blogs/metablog.ashx" type="Telerik.Blogs.MetaWeblog.MetaWeblogHandler, Telerik.Blogs" />
            <add name="TrackbackHandler" verb="POST" path="trackback.ashx" type="Telerik.Cms.Engine.Trackback.TrackbackHandler, Telerik.Cms.Engine" />
            <add name="S3StorageHandler" verb="GET" path="*.s3lb" type="Telerik.Libraries.AmazonStorage.S3StorageHandler, Telerik.Libraries" />
            <add name="S3StorageHandlerashx" verb="GET" path="*.s3lb.ashx" type="Telerik.Libraries.AmazonStorage.S3StorageHandler, Telerik.Libraries" />
            <add name="WebResource" verb="*" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
            <!--
            <add name="Cms" verb="*" path="Telerik.Cms.Web.CmsHttpModuleUrlRewrite.axd" type="Telerik.Cms.Web.CmsHttpModuleUrlRewrite, Telerik.Cms" preCondition="managedHandler" />
            -->
            
        </handlers>

    And here's my rewriter code:

    <rewriter>
       <rewrite url="test" to="Home.aspx" />
     </rewriter>


    I receive the following when navigating to "test" (with no extension):

    -----------------

    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: /Home.aspx
    -------------------

    You said to make sure "UrlRewrite module executes before the CmsHttpModule", but I don't know how to do that with web.config.

    As you can see, it's trying to reach Home.aspx, and in my modules section "UrlRewriter" appears before "Cms".
    Could you post the response sent to Matthew Snyder? And also provide a recommendation for those who must rely solely on web.config? Thanks

    -adam

  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Mar 2011
    Link to this post
    Hi Adam,

    This forum post will resolve the problem.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
Register for webinar
10 posts, 0 answered