locked
SPSecurity.RunWithElevatedPrivileges not getting called RRS feed

  • Question

  • Hi,
    I need to run code with elevated permissions so I am using :

    SPWeb myWeb = SPContext.Current.Web;
     SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite siteCollection = new SPSite(myWeb.Site.ID))
                        {
                            using (SPWeb web = siteCollection.OpenWeb(myWeb.ID))
                            {
    //Code Logic
    }
    }

    However the code inside Runwithelevated permissions is not getting called any hints why this is happening ??
    Monday, August 4, 2008 6:48 AM

Answers

  • Hi,
    if you set a breakpoint within your RunWithElevatedPrivileges, you will be able to debug. The "problem" you are experiencing is, that the code is executed as one statement.

    René

    visit my blog: http://www.hezser.de/blog
    • Marked as answer by Bhavna B Monday, August 4, 2008 8:20 AM
    Monday, August 4, 2008 7:32 AM