For learning purposes I am trying to create a low trust provider hosted app on my on prem SP2013 machine on a team site collection. I have created a new project with an MVC application template. When I press F5 the project runs and in the browser the application fails. The problems seems to be in the SharePoint context filter attribute. I get the can not redirect result. I have the same when using a webform provider hosted web.

I run the MVC app from IISExpress with anonymous auth. I have seen somewhere that I should disable anonymous. I trief that but didn't work.

What am I missing. Should the project created on the template not default work?

public class SharePointContextFilterAttribute : ActionFilterAttribute
    public override void OnActionExecuting(ActionExecutingContext filterContext)
        if (filterContext == null)
            throw new ArgumentNullException("filterContext");

        Uri redirectUrl;
        switch (SharePointContextProvider.CheckRedirectionStatus(filterContext.HttpContext, out redirectUrl))
            case RedirectionStatus.Ok:
            case RedirectionStatus.ShouldRedirect:
                filterContext.Result = new RedirectResult(redirectUrl.AbsoluteUri);
            case RedirectionStatus.CanNotRedirect:
                filterContext.Result = new ViewResult { ViewName = "Error" };
  • Check this and follow step by step sptechbytes.blogspot.in/2013/08/… – user13408 Aug 12 '17 at 16:01
  • I tried this before and I think then I could run from visual studio directly while pressing F5. Is there something changed in the TokenHelper? – Danny Aug 12 '17 at 17:04
  • I follow that website. Still the same issue. – Danny Aug 12 '17 at 18:11
  • This is the code that causes the error: – Danny Aug 12 '17 at 18:34
  • if (StringComparer.OrdinalIgnoreCase.Equals(httpContext.Request.HttpMethod, "POST")) { return RedirectionStatus.CanNotRedirect; } – Danny Aug 12 '17 at 18:34

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.