You need to return an ActionResult
from your controller to view, if you want to render some html. Otherwise, view will receive a string and display it as it is.
You can define a partial view which holds the html, and you can render this partial view in your main view.
public PartialViewResult MyActionLink()
{
return PartialView("_MyPartialView");
}
_MyPartialView
is just a view file holding the html you want to render.
However, I would suggest writing a custom html helper which I believe cleaner solution.
public static string MyActionLink(this HtmlHelper helper)
{
StringBuilder sb = new StringBuilder();
sb.Append("<div><p>");
sb.Append(helper.ActionLink("Text","Action","Controller"));
sb.Append("</p></div>")
return sb.ToString();
}
Then you can render this custom html helper in your view via
@Html.MyActionLink()