On HomeController.cs code :
if (User.Identity.IsAuthenticated)
{
var profile = Profile.GetProfile(User.Identity.Name);
ViewData["Message"] = "Welcome " + profile.FirstName + "!";
}
else
{
ViewData["Message"] = "Welcome to myblog.";
ViewData["RegisterLink"] = "please register <%:Html.ActionLink('Register', 'Register', 'Account')%>.";
}
If user is not logged in it should have to show
welcome to myblog and please register (it must be actionlink)
and on index.aspx inside Content code is:
<%: ViewData["RegisterLink"] %>
But I’m failed to generate ActionLink please help.
There are many different ways to tackle what you want, I prefer the strongly typed view approach but you could try the following:
Then inside your View, if
RegisterLinkis true, show the ActionLink().