Warren it's also worth mentioning more about the umbRequestHelper which wraps the $http promises and does proper error checking on results such as overlaying the ysod display when in debug mode if your request throws a 500 result.
for example when we call a service URL we might use:
Hi Shannon,
Trying to get the example in the docs running but not having much luck.
So on my ApplicationStarted event I have
//Umbraco JS Server Variables - To Register WebAPI Route URLs
ServerVariablesParser.Parsing = Parsing;
And the associated void to add the example keys on the docs
private void Parsing(object sender, Dictionary<string, object> dictionary)
{
//add stuff to the dictionary, preferably under your own custom section such as:
dictionary.Add("myPackage", new Dictionary<string, object>
{
{"mySetting1", "blah"},
{"mySetting2", "another value"}
});
}
I have stepped through the Parsing void never seems to fire, so hence they keys never get added. I am running 7.0.2 from NuGet and I am not getting any build or compilation errors, so I am unsure what I am doing wrong.
Well, turns out there are 2 things wrong :( The first one is easy:
You are not listing to the event properly, this is what you have:
ServerVariablesParser.Parsing = Parsing;
You need this:
ServerVariablesParser.Parsing += Parsing;
The second one is that it shouldn't let you have done that in the first place! And that is my fault, turns out I forgot to add the actual 'event' keyword to this delegate... lol, that's really dumb on my part!
I'll fix that up for 7.0.3 but I think just adding the + in your code might actually work, which is very strange since it's actually not declared as an event in c# :P
So one question for this:
Wanted to try it but the Url.GetUmbracoApiServiceBaseUrl isn't found at all.
Which using statement do i need when i want to use that method when the applications starts to register my urls to the servervariables?
Using Umbraco.Sys.ServerVariables for WebAPI Route URLs
Hello,
I have seen this post on the Umbraco.com site
https://umbraco.com/follow-us/blog-archive/2014/1/17/heads-up,-breaking-change-coming-in-702-and-62.aspx
And it mentions about using Umbraco.Sys.ServerVariables as a way to deliver the WebAPI Route URLs down to my JS for my AngularJS $http.get() calls.
So if anyone has any examples on how to use this, that would be fantastic.
Cheers,
Warren :)
Here you go:
http://our.umbraco.org/documentation/Extending-Umbraco/version7-assets
Warren it's also worth mentioning more about the umbRequestHelper which wraps the $http promises and does proper error checking on results such as overlaying the ysod display when in debug mode if your request throws a 500 result.
for example when we call a service URL we might use:
There's documentation about it too:
http://umbraco.github.io/Belle/#/tutorials/using-promises-resources http://umbraco.github.io/Belle/#/api/umbraco.services.umbRequestHelper
Hi Shannon,
Trying to get the example in the docs running but not having much luck.
So on my ApplicationStarted event I have
And the associated void to add the example keys on the docs
I have stepped through the Parsing void never seems to fire, so hence they keys never get added. I am running 7.0.2 from NuGet and I am not getting any build or compilation errors, so I am unsure what I am doing wrong.
Thanks,
Warren :)
Well, turns out there are 2 things wrong :( The first one is easy:
You are not listing to the event properly, this is what you have:
You need this:
The second one is that it shouldn't let you have done that in the first place! And that is my fault, turns out I forgot to add the actual 'event' keyword to this delegate... lol, that's really dumb on my part!
I'll fix that up for 7.0.3 but I think just adding the + in your code might actually work, which is very strange since it's actually not declared as an event in c# :P
So one question for this: Wanted to try it but the
Url.GetUmbracoApiServiceBaseUrl
isn't found at all. Which using statement do i need when i want to use that method when the applications starts to register my urls to the servervariables?Ok found it. You need the Umbraco.Web Namespace
For my own reference & for anyone else coming across this thread I have typed up a blog post on why you want to use this & bhow easy it is to do:
http://creativewebspecialist.co.uk/2014/06/23/what-on-earth-is-umbraco-servervariables-parsing/
is working on a reply...