Monday, September 16, 2019

Sharepoint 2013 MVC 5 provider-hosted app. Fails to authenticate using SharePointContextProvider.CheckRedirectionStatus

One of the reasons for this failure is SPHostUrl parameter has not been passed to the post action. It can be passed by several ways


  1. Use Html.BeginForm like so:
ViewBag.SPURL = Request.QueryString["SPHostUrl"];

And if the view

@using (Html.BeginForm("Upload", "Home", new { SPHostUrl = @ViewBag.SPURL }, FormMethod.Post, new { enctype = "multipart/form-data" }))



2. In C# pass the parameter in redirect statement


return RedirectToAction("Index", new {SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri});

References:








No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...