Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeremy M White 4 posts 24 karma points
    May 31, 2012 @ 08:31
    Jeremy M White
    0

    Infinite loop when Controller-Action creates and then redirects to content with same path

    I have a controller/action that creates content in the Umbraco content tree with the same path as the controller/action, but when it redirects to that content it recursively calls the action again and get stuck in an infinite loop?

    Situation:

    • Consider a controller named DocumentType with an action named Index that takes a parameter named Id
    • The controller responds to the route /DocumentType/Index/1234
    • I have created documents in the content tree mimicing the controller's route: /DocumentType/Index/1234
    • The routing should navigate to the document, if it exists, otherwise it should go to the action on the controller.
    • The action is responsible for creating new content at the requested path and then redirect to that content
    • The redirection is recursively calling the action on the controller instead of serving up the content that was just created

    Success:

    1. Manually create content /DocumentType/Index/5678 in content tree
    2. User navigates to http://website.com/DocumentType/Index/5678
    3. Umbraco returns content with correct template

    Fails:

    1. User navigates to http://website.com/DocumentType/Index/1234
    2. Content does not exist, so routed to Controller: DocumentType, Action: Index, Id: 1234
    3. Action creates new content at /DocumentType/Index/1234 and remembers HiveId of new item
    4. Action redirects to content of new HiveId
    5. *** Action /DocumentType/Index/1234 is called again, NOT the content in Umbraco ***

    How do I tell Umbraco to serve up the newly created content rather than redirecting me back to Controller/Action?

     

    Environment:

    • Umbraco Version: 5.1
    • Asp.Net Version: 4.0
    • Windows and IIS Version: Windows 7 and IIS Express 7.5

Please Sign in or register to post replies

Write your reply to:

Draft