SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need to customize public site and used custom login page for authenticated SharePoint Users.

i am follow below post :

and checked that we can accomplish authenticated using CSOM. so i have used below code.

here is code :

        string cmdSpoSite = "";
        string cmdUserName = "";
        string cmdPassword = "password";

        helper = new MsOnlineClaimsHelper(

        using (ClientContext ctx = new ClientContext(cmdSpoSite))
            ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(ctx_ExecutingWebRequest);

            if (ctx != null)
                ctx.Load(ctx.Web); // Query for Web
                ctx.ExecuteQuery(); // Execute

                lbltext.Text = ctx.Web.Title;

code is worked fine in console app. when moved on webpart of Sandbox solution it does not worked. but when i have used code on webpart in Farm Solution getting worked fine.

please guide we can used it or not?


share|improve this question
up vote 3 down vote accepted

Not in a sandbox solution no. You could however create the app running on a separate web server / app and call it in a iframe since it's client object model.

The reason it won't work is because the namespaces you require are blocked in sandbox.

share|improve this answer
sound like create asmx service or wcf service to accomplish this.Am i right? – Jigs May 14 '13 at 13:19
You don't need to, you can create a new web app for a basic site and use that for hosting apps. Really this would be a seperate server ideally. Then you can run your csom from there and have it come in a iframe on the page. The use has total transparency as to what is going on. Going forward this is a step towards the 2013 app model which is replacing sandbox. – Hugh Wood May 14 '13 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.