Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonathan Roberts 409 posts 1063 karma points
    Oct 16, 2015 @ 11:31
    Jonathan Roberts
    0

    Submit data to dll from AngularJS

    Hi, Is it possible to create a package which has a bespoke DLL and then in the AngularJS post to a method in the DLL?

    For example I want to call a Twitter Authentication bit of code that is in my own bespoke dll within AngularJS.

    I hope you can help

  • Comment author was deleted

    Oct 16, 2015 @ 11:46

    You'll need to look into api controllers https://our.umbraco.org/documentation/reference/routing/webapi/

  • Jonathan Roberts 409 posts 1063 karma points
    Oct 16, 2015 @ 12:27
    Jonathan Roberts
    0

    Hi Thanks for your reply. Im a little new to AngularJs and I was wondering if you knew what i was doing wrong?

    In my external Project whcih Im creating the DLL I do the following:

    using System.Web;
    using Umbraco.Web.WebApi;
    
    namespace Twitterpost
     {
    [Umbraco.Web.Mvc.PluginController("TwitterPost")]
    public class postTwitterController : UmbracoApiController
    {
    
        public Boolean postToTwitter(string message)
        { .....
    

    My Twitterpost.dll is in the main project BIN folder.

    And in my Package Controller (angularjs) I have the following:

     $scope.posted = $http.get('/Umbraco/TwitterPost/postTwitterController/postToTwitter?message=' + $scope.newsfeeddescription + '/'); 
    

    But Im getting a 404 error

    Can you see where im going wrong? Thanks for your help, Jon

  • Jonathan Roberts 409 posts 1063 karma points
    Oct 16, 2015 @ 13:14
    Jonathan Roberts
    0

    I have sorted it - I had to change the "get" to "post", then lower case Umbraco to umbraco, lower case PluginController name to "twitterpost" and then lower case the controller name and remove the word "controller" so it just says posttwitter. So it looks like this now: (I added a success and error to it too to work out the exact error):

     $scope.posted = $http.post('/umbraco/twitterpost/postTwitter/postToTwitter?message=' + $scope.newsfeeddescription + '/')
            .success(function(data) {
                alert(data);
            }).error(function(data, status) {
                alert(status);
            }); 
    

    Hope this helps someone else in the future - Thanks again Tim

Please Sign in or register to post replies

Write your reply to:

Draft