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

Forums / Developing with Sitefinity / directory browsing

directory browsing

4 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    04 Mar 2009
    Link to this post
    Hello,

    Quick question. We have a third party web service that accesses a specific directory on our site and since we switched over to Sitefinity the webservice can't access the directory properly because the extension ".aspx" is automatically being added (i.e. our directory is www.domainname.com/directory/ and sitefinity is changing that to www.domainname.com/directory/.aspx. Is there a way to stop sitefinity from adding that ".aspx" for that one directory only?

    Thanks,

    Kalvin
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Mar 2009
    Link to this post
    Hello Kalvin MacLeod,

    You could try the following

    Create an HttpModule that inherits IHttpModule and replace the path
    using System; 
    using System.Web; 
     
    /// <summary> 
    /// Summary description for RedirectHtml 
    /// </summary> 
    ///  
    namespace RedirectPages 
        public class BrowseFolder : IHttpModule 
        { 
            public void Dispose() 
            { 
            } 
     
            public void Init(HttpApplication application) 
            { 
                application.BeginRequest += new EventHandler(application_BeginRequest); 
            } 
     
            void application_BeginRequest(object sender, EventArgs e) 
            { 
                HttpContext context = HttpContext.Current; 
                 
                // here specify the path you want browse and escape .aspx 
                if (context.Request.RawUrl.Contains("/path/.aspx") && context.Items["cmspaegmode"] == null
                { 
     
                string newPath = context.Request.Url.ToString().Replace(".aspx"string.Empty); 
                context.Response.Redirect(newPath); 
                } 
                #region IHttpModule Members 
                #endregion 
            } 
     
        } 

    Then register the module in your web.config file under <httpModules> section. I hope this helps.

    Regards,
    Ivan Dimitrov
    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.
  3. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    12 Mar 2009
    Link to this post
    Hello Ivan,

    Thanks for the suggestion. I tried it and unfortunately it seems like the .aspx is being added after the httpmodules fire because i never see the "/path/.aspx" show up in the Raw URL. And I can't just use "/path/" because then it gets stuck in an infinite loop.

    Here's the code I'm using (straight from yours except I fixed the spelling on cmspagemode):
    using System;  
    using System.Web;  
     
    /// <summary>    
    /// Summary description for RedirectHtml    
    /// </summary>    
    ///     
    namespace RedirectPages  
    {  
        public class BrowseFolder : IHttpModule  
        {  
            public void Dispose()  
            {  
            }  
     
            public void Init(HttpApplication application)  
            {  
                application.BeginRequest += new EventHandler(application_BeginRequest);  
            }  
     
            void application_BeginRequest(object sender, EventArgs e)  
            {  
                HttpContext context = HttpContext.Current;  
     
                // here specify the path you want browse and escape .aspx    
                if (context.Request.RawUrl.Contains("/RePEc/.aspx") && context.Items["cmspagemode"] == null)  
                {  
     
                    string newPath = context.Request.Url.ToString().Replace(".aspx", string.Empty);  
                    context.Response.Redirect(newPath);  
                }  
     
                #region IHttpModule Members  
                #endregion  
            }  
     
        }  
    }   
     

    I've registered it in the web config and tried it in different orders, not knowing if that makes a difference. The module fires fine, but it nevers sees the /RePEc/.aspx path. I simply get the following error:

     

    Server Error in '/CHEPA_Sitefinity' Application.

    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: /CHEPA_Sitefinity/hello/RePEc/.aspx


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Mar 2009
    Link to this post
    Hi Kalvin MacLeod,

    If you have
     - IIS with wild card mapping;
     - No home page is set for the site.

     - you are using extensionless urls

    the code will not work and .aspx will be appended. You can also put similar logic to Application_BeginRequest in Global.asax.

    All the best,
    Ivan Dimitrov
    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.
Register for webinar
4 posts, 0 answered