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:

Regex obfuscate email

 Use this code in C# to obfuscate email using regex // Online C# Editor for free // Write, Edit and Run your C# code using C# Online Compile...