I'm currently creating an MVC ASP.NET application in which multiple widgets are loaded from a different location. I have most of the logic down, but I get stuck trying to load the widgets from a differnt location than the original one.
Everything was working when I used this
foreach (WidgetPrototype.Models.Widget widget in Model)
{
<blockquote style="border-style: outset">
@Html.Partial(widget.Name)
</blockquote>
}
But when I moved the files to test loading views from a different location, changing my code to
foreach (WidgetPrototype.Models.Widget widget in Model)
{
<blockquote style="border-style: outset">
@Html.Partial(@"D:\" + widget.Name + ".cshtml")
</blockquote>
}
It stopped working, and gave the error that the view could not be found, with the message:
[InvalidOperationException: The partial view 'D:\Clock.cshtml' was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Widgets/D:\Clock.cshtml.aspx ~/Views/Widgets/D:\Clock.cshtml.ascx ~/Views/Shared/D:\Clock.cshtml.aspx ~/Views/Shared/D:\Clock.cshtml.ascx ~/Views/Widgets/D:\Clock.cshtml.cshtml ~/Views/Widgets/D:\Clock.cshtml.vbhtml ~/Views/Shared/D:\Clock.cshtml.cshtml ~/Views/Shared/D:\Clock.cshtml.vbhtml]
So apparently it's still trying to find the files on a relative path in the project.
Is there a way to force it to just use the full path?