ActionLink

Vote:
 

In an article page I have a link to an author and I want to display information about that author when you click the link.

I don't have any "Author"-page for every author, instead I can access information about that author from a database.

Is it possible somehow to use @Html.ActionLink("Phil Smith", "Author", "SomeController", new {authorId=1}, null} and have a view for that action? Any suggestions?

#75115
Sep 18, 2013 9:53
Vote:
 

You should be able to add additional controllers that are ignored by CMS. For instance in your global.asax.cs:

protected override void RegisterRoutes(RouteCollection routes)
{
    base.RegisterRoutes(routes);

    routes.MapRoute("AdditionalDiagnosticRoutes", 
                    "diag/{controller}/{action}/{param}", 
                    new { action = "Index", param = RouteParameter.Optional });

}

    

I added some additional diagnostic controllers that are not part of the CMS page/block controllers.

And controller itself:

public class VersionController : Controller
{
    [Authorize(Roles = "CmsAdmins")]
    public ContentResult Index(string assemblyName)
    {
        var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
        var version = fvi.FileVersion;

        return new ContentResult { Content = "Current version: " + version };
    }
}

    

You would need to prefix Html.ActionLink to point to your controller's url.

#75150
Sep 18, 2013 16:11
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.