“Unknown User” error when creating SharePoint 2013 MVC Apps

Do you get this error?

Unknown User

Unable to determine your identity. Please try again by launching the app installed on your site.

Well, it’s quite possibly nothing to do with users, identities, or anything else related to security. This is the default text in the Views/Shared/error.cshtml file in the web project that’s generated for you when you create a new SharePoint MVC project.

So, this error is shown whenever there’s any unhandled exception in your app….and that could be anything, really. So you’ve got to start debugging it. That’s easy if you’re debugging locally: simply turn on break on exceptions by going to Debug -> Exception and checking the Common Language Runtime Exceptions in the Thrown column:

Now, if you’re developing an Autohosted app for SharePoint 2013, then it’ll be running in Azure. And if you’re unfortunate enough that you’re seeing the “Unknown Error” page in Azure but not locally, then you need to disable that error page and make sure you’re able to see the full exception detail.

To do that, browse to your Views/Shared/Error.cshtml file and remove it from your project. If you’re not using source control, then you’ll probably want to back it up somewhere else to restore it later – this is only for debugging.

Once you’ve got rid of it, you need to switch on exceptions from remote machines. Open your project’s main Web.config (in your web project root) and find the <system.web> tag. Add in the tag <customErrors mode=”Off”/>. It should look something like this:

Now when you run your project and reproduce the error, you’ll see a stack trace which should put you on the right track.


3 thoughts on ““Unknown User” error when creating SharePoint 2013 MVC Apps

  1. Hello Jonathan, Thanks for this post. I promise I am not googling your name all over the internet. well maybe. So I followed your article on code project and I run into this error. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. my guess is either the database was not created or something to do with the animaldbcontext call. In the animalcontroller, when creating the instance of the dbcontext, do you pass in the connectiong string, if yes, how?

    Thanks for you Post, very informational and good starting step into sp apps.

    • Hi Tony! Sorry for the delay, I just saw your comment.

      Check the section titled ‘Autohosted App SQL Connection String’ on the code project article. You need to load the connection string from the web.config, in a key called SqlAzureConnectionString. Set it to a connection string on localhost for debugging. When you deploy it, the deployment process will automatically set that web.config string to the correct value for the new database. This is for Autohosted apps only, though. Hope that helps!

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>