Hi I have a viewcomponet that read text from a txt file and i want to show that text in viewcomponent this is my ViewComponents ".cs"
public class MainFooterViewComponent:ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
{
string lastUpdateTime = System.IO.File.ReadAllText("./last.txt");
return View(last);
}
}
And in ".cshtml" i want to show "last"
<li>last" @last</li>
How can I do that in simple way
hhe common way to use view components
Inside of Shared folder you have to crate a Components folder and then MainFooter folder. Create the partial view MainFooter.cshtml there
Create class in a Controllers folder
Layout or main view