I have a solution that contains 2 projects. In the first I realized the User Controls and I want to use them in the second project. I publish the first project in DomaineName
and the second project in DomaineName/Directory
It's an ASP.net MVC3 solution, So I programmed a helper to add controls like this link http://malvinly.com/2011/02/28/using-web-forms-user-controls-in-an-asp-net-mvc-project/
public static HtmlString RenderControl<T>(this HtmlHelper helper, string path, Action<T> action) where T:UserControl
{
Page page= new Page();
T control = (T)page.LoadControl(path);
page.Controls.Add(control);
if (action != null)
{ action(control); }
using( StringWriter sw= new StringWriter())
{
HttpContext.Current.Server.Execute(page,sw,false);
return new HtmlString(sw.ToString());
}
}
In the master page of the second project I use the helper :
Html.RenderControl<BackOffice.Controls.widgetRecentComment>("../../Controls/widgetRecentComment.ascx")
But this error appears:
Cannot use a leading .. to exit above the top directory
And I can't use the ~
because my user controls are in DomaineName
and not DomaineName/Directory
Can you help me please ??