Copied to clipboard

Flag this post as spam?

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


  • Ross Ekberg 131 posts 382 karma points
    Jul 20, 2022 @ 14:25
    Ross Ekberg
    0

    Backoffice Routing Not Found

    I have a backoffice property editor that is a dropdown list that is meant to populate from a database. Here is the plugin controller, saved in the App_Code folder:

    namespace My.Controllers
    {
        public class Subscription
        {
            public int SubID { get; set; }
            public string Title { get; set; }
        }
    
        [Umbraco.Web.Mvc.PluginController("My")]
        public class SubscriptionPickerAPIController : UmbracoAuthorizedJsonController
        {
    
            public string GetAll()
            {
                List<Subscription> subs = new List<Subscription>();
                string conn = System.Configuration.ConfigurationManager.ConnectionStrings["WebSubscriptionsEntities"].ToString();
    
    
                conn = conn.Substring(conn.IndexOf("\"") + 1);
                conn = conn.Substring(0, conn.IndexOf("\""));
    
                using (SqlConnection connection = new SqlConnection(conn))
                {
                    connection.Open();
    
                    SqlCommand command = new SqlCommand("Select * from Subscriptions order by Title", connection);
    
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while(reader.Read())
                        {
                            Subscription thissub = new Subscription();
                            thissub.SubID = (int)reader[0];
                            thissub.Title = (string)reader[1];
                            subs.Add(thissub);
                        }
                    }
                }
    
                string output = new JavaScriptSerializer().Serialize(subs);
                return output;      
            }
        }
    }
    

    I have the following AngularJS resource calling it, saved in the App_Plugins folder:

    angular.module('umbraco.resources').factory('SubscriptionPickerResource',
        function ($q, $http) {            
            return {                
                getAll: function () {                
                    return $http.get("backoffice/My/SubscriptionPickerApi/GetAll/");
                }
            };
        }
    ); 
    

    My site runs over HTTPS. I have a redirect setup in IIS to direct all traffic to HTTPS. the web.config setting 'UmbracoUseSSL' is set to true.

    I keep getting a 404 error. I have tried a bunch of different URL iterations, all come back 404. When I examine the request, I see the URL is 'https://mydomain.com/umbraco/backoffice/My/SubscriptionPickerApi/GetAll/'

    What am I doing wrong?

  • Ross Ekberg 131 posts 382 karma points
    Jul 29, 2022 @ 21:11
    Ross Ekberg
    0

    Anyone?

  • Ross Ekberg 131 posts 382 karma points
    Aug 02, 2022 @ 14:04
    Ross Ekberg
    0

    Bueller?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies