public class BlogContainerController : BaseMvcController
{
public override ActionResult Index(RenderModel umbracoModel)
{
BlogContainer model = GetViewModel(umbracoModel);
return CurrentTemplate(model);
}
}
I cannot use return base(model); because my model is not inheriting RenderModel.
I am also using the Model Builder and extending them with my own partial classes:
Model
/// <summary>BlogContainer</summary>
[PublishedContentModel("blogContainer")]
public partial class BlogContainer
{
public new const string ModelTypeAlias = "blogContainer";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
public BlogContainer(IPublishedContent content)
: base(content)
{ }
//....
public partial class BlogContainer : PublishedContentModel
{
public IEnumerable<BlogArticle> ArticleList { get; set; }
public IEnumerable<BlogYearFolder> BlogYears { get; set; }
public IEnumerable<TagModel> TagList { get; set; }
}
Initially, I was using a partial view for this part but trying to troubleshoot, I placed it back in the parent view. I need to be able to pass in variables for the tags and attempted that first but no matter what I do - no url...
View
@inherits Umbraco.Web.Mvc.UmbracoViewPage<BlogContainer>
<div>
<h3>Tags</h3>
<ul>
@foreach (var tag in Model.TagList)
{
<li>
@Html.ActionLink(tag.Text, "Index", "BlogContainer", null , null)
<a href="@Url.Action("Index", "BlogContainer", null)"> test url</a>
</li>
}
</ul>
</div>
This is the HTML that is rendered:
Page
<div>
<h3>Tags</h3>
<ul>
<li>
<a href="">Brett Spencer</a>
<a> test url</a>
</li>
<li>
<a href="">Tag 1</a>
<a> test url</a>
</li>
<li>
<a href="">Tag2</a>
<a> test url</a>
</li>
</ul>
</div>
It seems the only way to generate a url is to use a Surface controller - that opens up a whole bunch of issues.
Now I can't easily use return CurrentTemplate(model);. I tried customizing the EnsurePhsyicalViewExists(template) function but that turned out to be way more work as I have to hijack the ViewEngine because Umbraco doesn't stick to the MVC pattern and places all of the Templates under the root of Views.
So to return the original Template or View (Blog), I had to magically string the view in the Surface Controller - return View("~/Views/Blog.cshtml", model);
It seems it is impossible to create an ActionLink() unless your using a Surface Controller!
Getting <a href>No Url</a> from ActionLink in Views
I've been searching online for hours and trying different things all-day.
As the title states, I cannot get @Html.Actionlink or the @Url.Action to generate a url. I have no idea why:
So, here is my setup:
Controller (BaseMvcController inherits RenderMvcController)
}
I cannot use
return base(model);
because my model is not inheriting RenderModel.I am also using the Model Builder and extending them with my own partial classes:
Model
//....
Initially, I was using a partial view for this part but trying to troubleshoot, I placed it back in the parent view. I need to be able to pass in variables for the tags and attempted that first but no matter what I do - no url...
View
This is the HTML that is rendered:
Page
Why is this not generating a url?
It seems the only way to generate a url is to use a Surface controller - that opens up a whole bunch of issues.
Now I can't easily use
return CurrentTemplate(model);
. I tried customizing theEnsurePhsyicalViewExists(template)
function but that turned out to be way more work as I have to hijack the ViewEngine because Umbraco doesn't stick to the MVC pattern and places all of the Templates under the root of Views.And my routing looks terrible:
So to return the original Template or View (Blog), I had to magically string the view in the Surface Controller -
return View("~/Views/Blog.cshtml", model);
It seems it is impossible to create an ActionLink() unless your using a Surface Controller!
is working on a reply...