I am attempting to get a partial view macro to work. But it doesn't.
My Model is EF6 so I don't know exactly how to paste it in here, but here is the specific table I am referencing. The context name is "WebSubscriptionsEntities":
namespace Bridge.Models
{
using System;
using System.Collections.Generic;
public partial class SubscriptionItem
{
public int SubItemID { get; set; }
public string title { get; set; }
public Nullable<System.DateTime> post_date { get; set; }
public string filename { get; set; }
public Nullable<bool> active { get; set; }
public string SubID { get; set; }
public string posted_by { get; set; }
public string pr_category_type { get; set; }
public Nullable<System.DateTime> last_modified_date { get; set; }
public string Last_modified_by { get; set; }
public Nullable<int> PressReleaseID { get; set; }
}
}
My Controller (WebSubscriptionsItemListController.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bridge.Models;
namespace Bridge.Controllers
{
public class WebSubscriptionsItemListController : Controller
{
// GET: WebSubscriptionsItemList
public ActionResult GetSubscriptionItems()
{
List<SubscriptionItem> subItems = GetItems();
return PartialView("WebSubscriptionItemList", subItems);
}
public List<SubscriptionItem> GetItems()
{
using (WebSubscriptionsEntities dc = new WebSubscriptionsEntities())
{
List<SubscriptionItem> itms = dc.SubscriptionItems.Where(x => x.SubID == "31").OrderByDescending(x => x.post_date).ToList();
return itms;
}
}
}
}
My Partial View (WebSubscriptionsItemList.cshtml):
Can't Get Partial View Macro To Work
I am attempting to get a partial view macro to work. But it doesn't.
My Model is EF6 so I don't know exactly how to paste it in here, but here is the specific table I am referencing. The context name is "WebSubscriptionsEntities":
My Controller (WebSubscriptionsItemListController.cs):
My Partial View (WebSubscriptionsItemList.cshtml):
My Partial View Macro (WebSubscriptionsItemList.cshtml):
The error I get is:
System.InvalidOperationException: No route in the route table matches the supplied values.
Hi Ross
I'm wondering if your routing issue is down to your Controller not being auto routed?
If you updated it to inherit from the special base Umbraco SurfaceController
public class WebSubscriptionsItemListController : SurfaceController
Whether that would resolve this particular issue
Regards
Marc
Originally, I tried this and nothing changed. However, I didn't realize that I needed to 'build'the project. Once I did that, I got a different error:
Ugh, I figured it out. There is a fricking typo in my controller.
is supposed to be:
Hi Ross
How very annoying, glad you got it working though!
regards
Marc
is working on a reply...