I just finished viewing the DNN advanced module development course (and prerequisites) and am trying to grasp everything.
While testing I can't seem to get an $http.get request working with additional parameters. The angular module code (00.00.02) has the "byid" example on the ItemController but this service never gets called from the client side so there is actually no example of GET with parameters. In my controller class the parameter object is always null.
Here are some snippets of what I've tried:
[HttpGet]
[ValidateAntiForgeryToken]
[ActionName("test")]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)]
public HttpResponseMessage GetTestByModuleId(ParamObject parameters)
{
try
{
var test = parameters.TestValue; // > the parameters object is always null so we fail here with an object not referenced to an instance of an object exception
...
The ParamObject:
public class ParamObject
{
public string TestValue { get; set; }
}
The Client side code:
$http.get(serviceRoot + 'slide/test', { params: { TestValue: "testvalue" } })
.then(function(response) {
vm.TestResult = response.data;
},
function(errorPayload) {
$log.error('Loading of testdata failed', errorPayload);
});
I have also tried some variations by using the [FromUri] attribute or by passing it in as a string and serializing and deserializing it but so far no success... Do you have an idea?