I connect to Umbraco CMS by core Umbraco libraries from external application. And I have problem, Umbraco.Web.UmbracoContext.Current is null.
I create new context by UmbracoContext.EnsureContext, but this couses exception (Current has not been initialized on Umbraco.Web.Routing.UrlProviderResolver. You must initialize Current before trying to read it.):
UmbracoContext umbracoContext =
UmbracoContext.EnsureContext(
new HttpContextWrapper(System.Web.HttpContext.Current),
ApplicationContext.Current,
new WebSecurity(new HttpContextWrapper(System.Web.HttpContext.Current), ApplicationContext.Current),
false);
var urlProvider = umbracoContext.UrlProvider;
This code couses exception too (An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code, additional information: Current has not been initialized on Umbraco.Web.PublishedCache.PublishedCachesResolver. You must initialize Current before trying to read it.):
UmbracoContext umbracoContext =
UmbracoContext.EnsureContext(
new HttpContextWrapper(System.Web.HttpContext.Current),
ApplicationContext.Current,
new WebSecurity(new HttpContextWrapper(System.Web.HttpContext.Current), ApplicationContext.Current),
false);
UmbracoHelper umbracoHelper = new UmbracoHelper(umbracoContext);
var image = umbracoHelper.Media(id);
Problem with UmbracoContext.Current
Hello,
I connect to Umbraco CMS by core Umbraco libraries from external application. And I have problem, Umbraco.Web.UmbracoContext.Current is null.
I create new context by UmbracoContext.EnsureContext, but this couses exception (Current has not been initialized on Umbraco.Web.Routing.UrlProviderResolver. You must initialize Current before trying to read it.):
This code couses exception too (An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code, additional information: Current has not been initialized on Umbraco.Web.PublishedCache.PublishedCachesResolver. You must initialize Current before trying to read it.):
Hello,
This Umbraco console app might be able to help. It also uses the API outside of a default Umbraco environment: https://github.com/sitereactor/umbraco-console-example
Jeroen
Petr,
See https://github.com/Isle-Of-Man-Government/IOMG.Umbraco.StandaloneServices this project shows you how to use umbraco in your own external application.
Regards
Ismail
Thanks. I test both ( https://github.com/sitereactor/umbraco-console-example and https://github.com/Isle-Of-Man-Government/IOMG.Umbraco.StandaloneServices) without success.
Notice:
Directly in Umbraco CMS project this work ok.
It don't work only when I connect to Umbraco CMS by Core Umbraco libraries from external application.
is working on a reply...