3

What I’m trying to achieve here is a MVC website that gets some info from SharePoint. I did that on VS 2017, works perfectly.

This is the code:

        var ctx = authManager.GetWebLoginClientContext("https://MYSITEURL");

        //using auto connect
        Web web = ctx.Web;
        User user = web.CurrentUser;
        ctx.Load(web);
        ctx.Load(user);
        //ctx.ExecuteQuery();
        ctx.ExecuteQuery();

        ViewBag.Site += web.Title;

Inside VS 2017 it works without any errors, on the remote host that ive got set up I get 503 Service Unavailable and it seems like its crashing the App Pool that I’ve for this web app.

My question is: Is there something wrong with using the code as I'm using it or is my IIS simply not configured correctly (first time configuring that annoying thing).

Edit: Just checked the logs, this is what shows up when the app pool crashes:

StackTrace:    at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at OfficeDevPnP.Core.AuthenticationManager.<>c__DisplayClass20_0.<GetWebLoginClientContext>b__0()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
  • Is this from SharePoint PnP Core library <OfficeDevPnP.Core>? – user13408 Feb 25 '18 at 17:38
  • Yep, im using that one. The error is somewhat related (i suppose?), but still no idea whats the problem exactly. – Dante R. Feb 25 '18 at 18:01
  • It seems that it tries to open a win32 window for authenticating the user. I don’t think that this approach is valid for web app. – Lukas Nespor Feb 25 '18 at 21:50
  • Yep, System.Windows.Forms.Form.ShowDialog is key here. That is an application window and you should expect the App Pool to crash. – Trevor Seward Feb 25 '18 at 22:15
  • Hmm, is there any way to change the code so it works as an MVC ? (pretty new to c# here, still learning) – Dante R. Feb 26 '18 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.