No type was found that matches the controller named ...

No type was found that matches the controller named ...

montoyammontoyam Posts: 568Questions: 136Answers: 5

I created a simple sql table to add a datagrid to an existing project. The existing project was created using the Editor Generator and the existing grids work fine. The new grid I tried adding gives me the error:

No type was found that matches the controller named 'test'

When I use the Generator to create a new project with this sample test grid it loads just fine. I then merely copy/pasted the code form the new project to the existing project and I still got the 'no type found' error. Why does it work on a stand-alone project created by the generator but not when added to an existing project. does the generator do some type of registering that I need to do manually when adding a grid?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Where does that error popup please? Also, can you show me your controller code? And have you loaded the DataTables.dll as a reference?

    Thanks,
    Allan

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    so i changed it from 'test' in case there was some issue with 'reserved words' or something. I figure make it a real table that I need anyway. still no luck. I added the new table to existing pages. It is the first one called BillingMethods. Again, all the other tables that were created using the generator work, except any new ones I add:

    /*
     * Model for DB table Categories
     * Created by http://editor.datatables.net/generator
     */
    using System;
    
    namespace Billing.Models
    {
    
        public class BillingMethodModel
        {
            public int BillingMethodID { get; set; }
            public string BillingMethod { get; set; }
        }
    
        public class LineItemCategoryModel 
        {
            public int CategoryID { get; set; }
            public string category { get; set; }
            public string sortby { get; set; }
        }
    
        public class LineItemsModel
        {
            public int LineItemID { get; set; }
            public string LineItem { get; set; }
            public int CategoryID { get; set; }
            public string sortby { get; set; }
        }
    
        public class BillingSetup_UnitRatesModel
        {
            public int LineItemID { get; set; }
            public string effectivedate { get; set; }
            public string expiredate { get; set; }
            public string unitrate { get; set; }
        }
            
    }
    
                /*
                 * Controller for DB table Categories
                 * Created by http://editor.datatables.net/generator
                 */
                
                using System;
                using System.Collections.Generic;
                using System.Net.Http.Formatting;
                using System.Web;
                
                using System.Web.Http;
                using DataTables;
                using Billing.Models;
                
                namespace Billing.Controllers
                {
    
                    public class BillingMethodController : ApiController
                    {
                        [Route("api/billingMethods")]
                        [HttpGet]
                        [HttpPost]
                        public IHttpActionResult BillingMethods()
                        {
                            var request = HttpContext.Current.Request;
                            var settings = Properties.Settings.Default;
    
                            using (var db = new Database(settings.DbType, settings.DbConnection))
                            {
                                var response = new Editor(db, "ProjectSetup_BillingMethods", "BillingMethodID")
                                    .Model<BillingMethodModel>()
                                     .Process(request)
                                    .Data();
    
                                return Json(response);
                            }
                        }
                    }
    
                    public class LineItemCategoriesController : ApiController
                    {
                        [Route("api/LineItemCategories")]
                        [HttpGet]
                        [HttpPost]
                        public IHttpActionResult Categories()
                        {
                            var request = HttpContext.Current.Request;
                            var settings = Properties.Settings.Default;
                
                            using (var db = new Database(settings.DbType, settings.DbConnection))
                            {
                                var response = new Editor(db, "InvoiceStructure_Categories", "CategoryID")
                                    .Model<LineItemCategoryModel>()
                                    .Process(request)
                                    .Data();
    
                                return Json(response);
                            }
                        }
                    }
    
    
    
                    public class LineItemsController : ApiController
                    {
                        [Route("api/LineItems")]
                        [HttpGet]
                        [HttpPost]
                        public IHttpActionResult LineItems()
                        {
                            var request = HttpContext.Current.Request;
                            var settings = Properties.Settings.Default;
    
                            using (var db = new Database(settings.DbType, settings.DbConnection))
                            {
                                var response = new Editor(db, "InvoiceStructure_LineItems", "LineItemID")
                                    .Model<LineItemsModel>("InvoiceStructure_LineItems")
                                    .Model<LineItemCategoryModel>("InvoiceStructure_Categories")
                                    .Field(new Field("InvoiceStructure_LineItems.LineItemID"))
                                    .Field(new Field("InvoiceStructure_LineItems.LineItem")
                                        .Validator(Validation.NotEmpty())
                                    )
                                    .Field(new Field("InvoiceStructure_LineItems.CategoryID")
                                        .Validator(Validation.NotEmpty())
                                        .Validator(Validation.Numeric())
                                        .Options("InvoiceStructure_Categories","CategoryID","Category")
                                    )
                                    .Field(new Field("InvoiceStructure_LineItems.sortby")
                                        .Validator(Validation.NotEmpty())
                                    )
                                    .LeftJoin("InvoiceStructure_Categories", "InvoiceStructure_LineItems.CategoryID", "=", "InvoiceStructure_Categories.CategoryID")
                                    .Where("InvoiceStructure_LineItems.CategoryID", request.Form["InvoiceStructure_LineItems.CategoryID"])
                                    .Process(request)
                                    .Data();
    
                                return Json(response);
                            }
                        }
                    }
    
                    public class BillingSetup_UnitRatesController : ApiController
                    {
                        [Route("api/BillingSetup_UnitRates")]
                        [HttpGet]
                        [HttpPost]
                        public IHttpActionResult BillingSetup_UnitRates()
    
                        {
                            var request = HttpContext.Current.Request;
                            var settings = Properties.Settings.Default;
    
                            using (var db = new Database(settings.DbType, settings.DbConnection))
                            {
                                var response = new Editor(db, "BillingSetup_UnitRates", "UnitRateID")
                                    .Model<BillingSetup_UnitRatesModel>("BillingSetup_UnitRates")
                                    .Model<LineItemsModel>("InvoiceStructure_LineItems")
                                    .Field(new Field("BillingSetup_UnitRates.LineItemID")
                                        .Validator(Validation.NotEmpty())
                                        .Validator(Validation.Numeric())
                                        .Options(new Options()
                                                    .Table("InvoiceStructure_LineItems")
                                                    .Value("LineItemID")
                                                    .Label("LineItem")
                                        )
                                     )
                                    .Field(new Field("BillingSetup_UnitRates.effectivedate"))
                                    .Field(new Field("BillingSetup_UnitRates.expiredate"))
                                    .Field(new Field("BillingSetup_UnitRates.unitrate"))
                                     .LeftJoin("InvoiceStructure_LineItems", "BillingSetup_UnitRates.LineItemID", "=", "InvoiceStructure_LineItems.LineItemID")
                                    .Where("BillingSetup_UnitRates.LineItemID", request.Form["BillingSetup_UnitRates.LineItemID"])
                                    .Process(request)
                                    .Data();
                                return Json(response);
                            }
                        }
                    }
    
                }
    

    table id = BillingMethods - ajax error.

    Message: "No HTTP resource was found that matches the request URI 'http://localhost:56013/api/billingMethods?_=1577127537904'."
    MessageDetail: "No type was found that matches the controller named 'billingMethods'."
    
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Do you have your BillingMethodController being imported in the program somewhere? I'm wondering if its just not being used! Also, is it an Generator program you are adding this to? If so, have you updated all of the namespaces accordingly to match?

    Allan

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    sorry, I don't understand the questions. I have one controller file and one model file containing all the data for all the data grids. Most work, but the new one doesn't.

    What do you mean by "being imported"?
    I believe they are all in the same namespace: namespace Billing.Controllers. Am I missing something?

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    I found a post somewhere that talked about a temp file that may need to be deleted: MS-ApiControllerTypeCache.xml. Lo and behold, when I look at the contents it does not have the new controller that I added. However, when I delete the file, rerun the package, the xml file that gets recreated still does not have the new controller. Why isn't it getting added?

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--This file is automatically generated. Please do not modify the contents of this file.-->
    
    -<typeCache mvcVersionId="403f4306-ee5b-4ec4-91db-0e04b481a826" lastModified="12/31/2019 11:33:30 AM">
    
    
    -<assembly name="Billing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    
    
    -<module versionId="071d30a4-6a67-4d56-86c6-3734d6556ce4">
    
    <type>Billing.Controllers.LineItemCategoriesController</type>
    
    <type>Billing.Controllers.LineItemsController</type>
    
    <type>Billing.Controllers.BillingSetup_UnitRatesController</type>
    
    </module>
    
    </assembly>
    
    </typeCache>
    
  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    ok. this is crazy...after rebooting, clearing cache, deleting that cache.xml file...nothing..that one controller is still not registering. So then I delete the controlers.cs file from the project compeltely, figuring now there wont' be any controllers registered....nope...it ran pefectly (except that one missing controller). How is it not crashing with the controller.cs file missing??????? I cleared cache and everything one more time after deleting the file. Where is this controller data getting stored and why is it not refreshing?

  • montoyammontoyam Posts: 568Questions: 136Answers: 5
    Answer ✓

    i went ahead and started a whole new VS project. I then copied and pasted the code from the old to the new. Everything worked perfectly. I had another post here about a drop-down not populating. That was fixed too!!! The code was right the whole time...it is just something with the project was not refreshing with the new controllers!!!

This discussion has been closed.