Copied to clipboard

Flag this post as spam?

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


  • Ian Smedley 97 posts 192 karma points
    Jan 10, 2011 @ 10:29
    Ian Smedley
    0

    Using ?delete= query string causes issues in Umbraco 4.5.3

    Hi Guys,

    I recently found this and thought I'd share it with you, in case anybody else also comes across it.[I couldn't find it in a quick search already]

    I had a usercontrol in the backend site which was using the query string:

    ?delete=somestringidentifier 

    This started to cause problems, when the string was not numeric, the action was not being carried out as expected, and throwing errors.

    I quickly tracked it down to KeyValuePrevalueEditor.cs in umbraco.editorControls.KeyValuePrevalueEditor - you can guess what's coming... I found this code:

    // Bootstrap delete.
    if (System.Web.HttpContext.Current.Request["delete"] != null) {
        DeletePrevalue(int.Parse(System.Web.HttpContext.Current.Request["delete"]));
        }
    }
    
    private void DeletePrevalue(int id) {
        SqlHelper.ExecuteNonQuery("delete from cmsDataTypePreValues where id = " + id);
    }

    Looks like my choice of querystring has already been taken!! A string value wouldn't cast to an integer and threw an exception!

    Quick fix: Change your query string!!

     

    Hopefully this should help someone else out, by either avoiding this in the first place, or looking for the solution using the search.

Please Sign in or register to post replies

Write your reply to:

Draft