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

Forums / Developing with Sitefinity / 404 Issue with root level documents

404 Issue with root level documents

4 posts, 1 answered
  1. mcpdinkansas
    mcpdinkansas avatar
    102 posts
    Registered:
    22 Mar 2007
    02 Jun 2010
    Link to this post
    Issue:

    We were given the task to convert an all html site into a Sitefinity site. Thousands of pages, and hundreds of documents/images.

    To save time, we have stored all documents to a root level directory folder called /TempDocuments and created a custom redirect when any page accesses a document via a link pointing to /documents/ we redirect the repsonse to point them to the /TempDocuments folder until we can get all these into Sitefinity modules for file management.

    Long story short, this method works well in Firefox, but for some reason IE gives a 404.

    Thoughts?

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Jun 2010
    Link to this post
    Hi mcpdinkansas,

    Thank you for using our services.

    Could you please let us know how/where are you making the redirect? I think that the most suitable way to do is to create a custom http module which will catch the request and perform a response redirect with 302 status code. Consider the very basic sample bellow. In this situation I have moved my files from ~/Files to ~/Images. And I have created the IHttpModule to handle this:
    using System;
    using System.Web;
     
    namespace Sitefinity.Samples
    {
        /// <summary>
        /// Summary description for SampleHttpModule
        /// </summary>
        public class SampleHttpModule : IHttpModule
        {
            #region IHttpModule Members
     
            public void Dispose()
            {
     
            }
     
            public void Init(HttpApplication context)
            {
                this.context = context;
                context.BeginRequest += new EventHandler(context_BeginRequest);
            }
     
            void context_BeginRequest(object sender, EventArgs e)
            {
                HttpRequest currentRequest = this.context.Context.Request;
                if (currentRequest.RawUrl.Contains("/Files/"))
                {
                    this.context.Response.StatusCode = 302;
                    this.context.Response.Redirect(currentRequest.RawUrl.Replace("/Files", "/Images"));
                }
            }
     
            #endregion
     
            #region Private Fields
     
            private HttpApplication context;
     
            #endregion
        }
    }

    Then I have registered my  http module in the web.config both for IIS 6 and IIS7:
    <httpModules>
        <add name="FilesRedirect" type="Sitefinity.Samples.SampleHttpModule, App_Code"/>
        <add name="ScriptModule" 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" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
    </httpModules>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
            <remove name="ScriptModule" />
            <remove name="Cms" />
            <remove name="FilesRedirect"/>
            <!--<remove name="LibraryModule"/>-->
            <remove name="RadUploadModule" />
            <add name="FilesRedirect" type="Sitefinity.Samples.SampleHttpModule, App_Code"/>
            <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" />
        </modules>


    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.
    Answered
  3. mcpdinkansas
    mcpdinkansas avatar
    102 posts
    Registered:
    22 Mar 2007
    03 Jun 2010
    Link to this post
    Thanks for the help Radoslav.

    I was doing the redirects within the global.asax within Application_BeginRequest. I moved this code to an HttpModule as you described without any luck.

    The issue was we had the document extensions within the mappings in IIS, causing this issue. I do like the HttpModule better, seems like a lot cleaner approach.

    Thanks for all your help!
  4. Richard
    Richard avatar
    24 posts
    Registered:
    25 Apr 2008
    03 Jun 2010
    Link to this post
    If you're using IIS 7 on Windows 2008 I'd recommend URL Rewrite 2.0. It works well with Sitefinity and it's easy to use. It can do all sorts of redirects as well as URL rewriting.

    http://www.iis.net/download/urlrewrite
Register for webinar
4 posts, 1 answered