Results 1 to 7 of 7

Thread: Two pages, same name, different folders

  1. #1
    Join Date
    May 2005
    Posts
    13

    Default Two pages, same name, different folders

    Hi

    I have two pages with the same name, News.aspx, one in the root of my application, one in an Admin subfolder, accessed as follows:

    www.mydomain.com/news.aspx

    www.mydomain.com/admin/news.aspx

    The problem I'm encountering is that I can only access which ever one appears last in my web.config. i.e. if I navigate to .../news.aspx then navigate to .../admin/news.aspx I get the .../news.aspx page being display on both occasions...even though the browser address control correctly shows the appropriate path.

    My object definitions in the web.config for each page are as follows:

    Code:
    <object name="admin_news" type="~/Admin/News.aspx" parent="list">
    </object>
    
    <object name="news" type="News.aspx" parent="ShopFront">
    </object>
    As a workaround I'm going to rename one of the pages, but should the above be possible? My Admin folder is not a virtual directory as I'm not able to set them up with my hosting company.

    Thanks in advance for any help.

  2. #2
    Join Date
    Sep 2004
    Location
    Belgrade, Serbia
    Posts
    613

    Default

    You need to use hierarchical contexts in this case and define admin news page within web.config in your admin directory.

    I saw another of your posts where you had a problem getting hierarchical contexts to work properly, so the following should address that issue as well.

    This is sample root Web.config:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
            
        <configSections>
            <sectionGroup name="spring">
                <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
                <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
            </sectionGroup>
        </configSections>
    
        <spring>
        
            <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
                <resource uri="config&#58;//spring/objects"/>
            </context>
            
            <objects>
    
                <object type="News.aspx"/>
    
            </objects>  
    
        </spring>
                
        <system.web>
    
            <httpHandlers>
                <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
                <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/>
            </httpHandlers>
    
            ... 
            
        </system.web>
    
    </configuration>
    And here is the sample Web.config within your admin directory:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
            
        <spring>
            
            <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
                <resource uri="config&#58;//spring/objects"/>
            </context>
        
            <objects>
                
                <object type="News.aspx"/>
                
            </objects>  
            
        </spring>
                
    </configuration>
    As you can see, all you need within child context definition is context definition and object definitions. I tried this example and it works properly -- I didn't have the problem you encountered with first accessed page always being returned.

    Let me know if this helps.

    Later,

    Aleks

  3. #3
    Join Date
    Feb 2007
    Posts
    1

    Default

    Hi, I am also encountering the similar problem. And I saw hierarchical contexts would be the solution. But my personal preference would be to put all difinitions of pages into one central location, so the page flow could be more intuitive and easier to manage here. Do you any plan to support that later?

  4. #4
    Join Date
    Jan 2006
    Location
    Cambridge, UK
    Posts
    1,340

    Default

    Hi,

    in short: yes. It's actually one of our open JIRA issues SPRNET-389.

    At the moment only the page's filename is used as object-id. This id will change to using the full virtual path of the page.

    cheers,
    Erich

  5. #5
    Join Date
    Jun 2005
    Posts
    33

    Default I have the same problem

    See also my thread on the same subject:
    http://forum.springframework.net/showthread.php?t=1611

    Changing to local Web.config files does not work well for me because this introduces new problems, namely unstable dependancy injection on the two first pageloads.

    This does not seem to be an issue when configuring .aspx-files in a file (which is my preference also), but this of course introduces the naming-problem instead.
    Am I right to assume that configuration in Web.config files are somehow bound later than configuration loaded from files?

    Erich, check out my two last post in that tread for more information.
    Bjørn Wang

  6. #6
    Join Date
    Jan 2006
    Location
    Cambridge, UK
    Posts
    1,340

    Default

    Hi,

    Am I right to assume that configuration in Web.config files are somehow bound later than configuration loaded from files?
    No. Objectdefinitions are parsed. created and merged in order of their appearence within the <context> section. E.g.

    Code:
    <spring>
      <context>
         <resource uri="assembly://myassembly/Namespace/assemblyobjects.xml" />
         <resource uri="web://~webobjects.xml" />
         <resource uri="config://spring/sectionobjects" />
      </context>
    </spring>
    will parse object definitions in order assemblyobjects.xml, webojbects.xml and sectionobjects.xml (possibly overriding already existing definitions!). After parsing and creating all definitions, singletons get instantiated.

    @bjorn: I'm really sorry - I've been thinking a lot about your problem, but have no idea, why it doesn't work for you. Maybe you could produce a DEBUG-log file and email me?

    cheers,
    Erich

  7. #7
    Join Date
    Jun 2005
    Posts
    33

    Default The cause of the problem

    Hello Erich,

    First of all: I'm very thankful for the kind interest that both you and Mark has taken in my problems with Spring. While I'm hugely impressed with Spring, your helpful support is what really makes the project shine for me. Your helpful advice is very much appreciated.

    For my problem, I've narrowed it down to how the CMS we're using handles URL-rewrites to produce friendly URLs. Thus, my problem should have no bearing for CheekyTinker's problem.

    I've started a separate thread for this problem:
    http://forum.springframework.net/sho...=5382#post5382
    Bjørn Wang

Similar Threads

  1. Applying AOP to aspx pages
    By equiv in forum Web
    Replies: 4
    Last Post: 05-17-2006, 01:50 AM
  2. Replies: 0
    Last Post: 05-11-2006, 12:03 PM
  3. Master pages strangeness on IIS6
    By dimitrod in forum Web
    Replies: 3
    Last Post: 04-26-2006, 09:46 PM
  4. Replies: 1
    Last Post: 11-24-2005, 11:25 PM
  5. having it ignore non spring pages
    By jacksonpd in forum Web
    Replies: 2
    Last Post: 04-27-2005, 06:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •