Reputation: 183
I've got some html code in my View. For example:
<b>Some text</b>
<p style="color:#337ab7">
Some other text
<a href="~/Content/files/my file_form.pdf" style="font-size:smaller; text-decoration:underline" target="_blank">SEE CONTENT</a>
</p>
As You can see, the code contains the link to some .pdf. It works fine. Instead of this I want to be able read the html from the string I provide via the class:
public static class ResourceParser
{
public static string GetTextFromResource(string keyValue)
{
var path = "MyProject.MyRepository.App_GlobalResources.pl";
var res_manager = new ResourceManager(path, typeof(pl).Assembly);
return res_manager.GetString(keyValue);
}
}
So instead of this html code in my View I'd want to have something like:
@Html.Raw(ResourceParser.GetTextFromResource("textAfterAllDataOnEmployeeEditPage"))
to load my html from resources. The problem is that when I use it like this, the link does not work and the site shows an 404 error.
Upvotes: 0
Views: 125
Reputation: 251072
The simplest solution is to use root-relative links in your HTML string, for example you need to replace:
href="~/Content/etc.pdf"
With
href="/Content/etc.pdf"
In your specific case, this will solve the problem. The special character ~
in your view gets parsed into the full path, it's not a feature of HTML.
Upvotes: 1