0

I'm trying to use the Umbraco ContentService in an external MVC application.

In my controller:

var contentService = new ContentService();
var document = contentService.GetById(idofdocumenthere);

I put my umbraco connectionstring in the web.config file with providerName="System.Data.SqlClient.

This is the error I get after running this code:

You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' 
to use an sql syntax provider

Parameter name: SqlSyntaxProvider

I also checked this link, but this didn't work.

Thanks in advance!

Community
  • 1
  • 1
Sllix
  • 606
  • 9
  • 28

1 Answers1

0

Don't instantiate a new ContextService, use the ApplicationContext.Current.Services.ContentService.

dampee
  • 3,392
  • 1
  • 21
  • 37
  • You mean: `ApplicationContext.Current.Services.ContentService`, but ApplicationContext.Current is always null. How can I fix this? – Sllix Mar 03 '14 at 08:46
  • Yes, I meant .current! Fixed it above :-) It can't be null if you are running in a webcontext. If it's null, the webapplication didn't boot correctly! ApplicationContext.Current when IIS launches the website. – dampee Mar 04 '14 at 09:51