Question

I am trying to develop my first SharePoint App. I have a Development Environment on Azure and Visual Studio 2013.

Then i create my app project by using the default Visual Studio 2013 (it's the same on Visual Studio 2012 i think) SharePoint App Template by going to

Click File -> New -> Project and choose App for SharePoint 2013

Then i choose Autohosted and select the sharepoint site i want to use for debug. Everything works fine.

Since this templates are supposed to run out of box, i press f5 for deubug. At first all seems well. Connection to Sharepoint is correctly made and i am presented with the following screen:

SharePoint App Permissions

I press "Trust It" Option and i get the following screen:

Unknown User

I should be getting something like

enter image description here

I don't get this. If i have so much problems debugging the default sharepoint app imagine when i have to get to serious development... I am starting to get nervous about using SharePoint Apps. Does anyone is successfully eveloping apps?

EDIT:

After making some debug i found out the following:

On SharePointContextFilterAttribute.cs it always falls on:

RedirectionStatus.CanNotRedirect:
                    filterContext.Result = new ViewResult { ViewName = "Error" };
                    break;

If i drilled down a bit and i found out that before this, when it doesn't find a SharePoint Context it tries to create one and it fails here:

 string spAppWebUrlString = TokenHelper.EnsureTrailingSlash(httpRequest.QueryString[SharePointContext.SPAppWebUrlKey]);

There is no key for SPAppWebURL on httpRequest... Don't now why or even if this is supposed to.

Then, after this fails, it falls on SharePointContext.cs CheckRedirectStatus() method:

if (StringComparer.OrdinalIgnoreCase.Equals(httpContext.Request.HttpMethod, "POST"))
            {
                return RedirectionStatus.CanNotRedirect;
            }

It's really easy to replicate and test this. Just create a Developer Site and create a new SharePoint App Project (MVC or WebPages it doesn't matter since you are not changing any code).

After that just press f5 and test it against our SharePoint developer site. It is allegedly really easy to start...

Was it helpful?

Solution

Found out the problem.

I was making quite a few mistakes:

  1. Creating a Autohosted App:

    • For this you need to debug your app on Sharepoint Online
    • If you have your own SharePoint instalation it won't work
  2. Provider-Hosted App

    • You need a few pre-requisites to use this one.
    • You need to create a high-trust app for SP2013 and generate the appropriate certificates. Here's How

How to: Create high-trust apps for SharePoint 2013 using the server-to-server protocol (advanced topic)

Hope this helps others that are starting on app development as i am.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top