Hi sunkana,
Use HtmlHelper.Raw that rendered as HTML markup.
Check this example. Now please take its reference and correct your code.
Index Model
public class IndexModel : PageModel
{
public string Message { get; set; }
public void OnGet()
{
this.Message = GetMessage();
}
public string GetMessage()
{
string myUrl = "https://www.aspsnippets.com";
return "Click " + "<a href= '" + myUrl + "' target='_blank'>Here</a>";
}
}
Razor View
@page
@addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
@model Link_Message_Razor.Pages.IndexModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@Html.Raw(Model.Message)
</body>
</html>
Screenshot