tags:

views:

141

answers:

2

I have an image gallery which has the following route:

    // gallery id
    routes.MapRoute(
       "gallery-route",
       "gallery/{galleryID}/{imageID}/{title}",
       new { controller = "Gallery", action = "Index", galleryID = (string)null, imageID = (string) null, title = (string) null},
       new { galleryID = @"\d+" }
    );

I can have URLS like :

example.com/gallery/4/23 - shows gallery 4 and image 23

example.com/gallery/4 - shows gallery 4 and first image in that gallery

I was trying to make an 'edit in place' mode which lets an administrator edit the images and running into several issues. Currently the editing functionality is non-AJAX.

1) How should i keep a 'sticky' edit mode parameter. There won't be an 'edit' button next to each image. i want the edit mode to be 'sticky', but then I'm finding I either need to set it in session or add a parameter to every single link on the page which is clumsy.

2) I have caching enabled for this view. Therefore if i make a change and refresh - the original cached view remains.

Can anyone give me any thoughts?

A: 

why not change the output on the view depending on the users authorisation status. Using inline code and Html helper functions in the ascx to either write out the values in HTML for readonly roles and for editor roles add a post form around input controls with the current values in. Then on the controller handle post in a separate procedure to save the edits.

or simply add an edit view ascx as well as a read view ascx.

Also when the post controller procedure fires replace the cache object with the new data recorded in the post.

finally of you have image caching problems when administering the gallery. Try adding a random string to the query eg:

function GetNewUrl(url)
{
Random rnd = new Random();

return url +"?"+rnd.Next(1000).ToString();

}
Richard
how do i do this : "Also when the post controller procedure fires replace the cache object with the new data recorded in the post." ? that would go a long way to solving the caching problem. i didnt know if this was possible
Simon_Weaver
i was thinking you meant replacing the ASP.NET cache object, but re-reading this i think you're meaning a data cache.
Simon_Weaver
A: 

You need to flush the cache for the page when a change is made. Don't show the cached page or cache the page when the user is logged in as administrator, as they will have a different view with edit controls etc. For a sticky mode where an administrator can choose to be in edit mode throughout the site this would have to be stored in the session. I use something based on this for caching controller actions, with an additional method to determine whether to cache the output/use the cached output.

stevehodgkiss