and when I run my Umbraco site in Microsoft Visual Studio and request the url http://localhost:<port>/feed.xml it returns the expected xml to me.
So here is my problem:
I want to create the controller and the custom application event handler into a package so I can import my features into another custom umbraco solution.
When I created the package and import it into another solution I see that my two files is installed correctly but when i try to enter http://domain.tld/feed.xml I get following error:
Value cannot be null.
Parameter name: umbracoContext
Notice that I've tried to hack this by re-building the umbraco context in the controller ctor.
So if I take the now "not-included" controller and include it into visual studio again it works.
UmbracoContext null
Hi guys'n'girls.
Been working on an mvc controller with an endpoint that will return xml to the requesting client.
My controllers code looks like this:
[PluginController("Foo")]
public class FeedController : UmbracoController
{
public FeedController() : base(UmbracoContext.EnsureContext(new HttpContextWrapper(System.Web.HttpContext.Current), ApplicationContext.Current, new WebSecurity(new HttpContextWrapper(System.Web.HttpContext.Current), ApplicationContext.Current), true))
{
}
[System.Web.Http.HttpGet]
public XmlActionResult Publish()
{
var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("count", 10));
return new XmlActionResult(document);
}
}
and i've created a custom application event handler that looks like this:
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RouteTable.Routes.MapRoute("Feed", "feed.xml", new { controller = "Feed", action = "Publish" });
}
and when I run my Umbraco site in Microsoft Visual Studio and request the url http://localhost:<port>/feed.xml it returns the expected xml to me.
So here is my problem:
I want to create the controller and the custom application event handler into a package so I can import my features into another custom umbraco solution.
When I created the package and import it into another solution I see that my two files is installed correctly but when i try to enter http://domain.tld/feed.xml I get following error:
Value cannot be null.
Parameter name: umbracoContext
Notice that I've tried to hack this by re-building the umbraco context in the controller ctor.
So if I take the now "not-included" controller and include it into visual studio again it works.
Any ideas ?
Thanks
Btw - using umbraco v. 7
Hello,
Are you inheriting from the correct controller? Did you try the Umbraco Web API?
Jeroen
Hi Jeroen:
I'm using the umbracocontroller otherwise if I use the web api controller my umbracocontext issue will be permanent.
is working on a reply...