Я только что установил MVC3 и VS 2010 express.
Пишу свое первое приложение в MVC3, но не мое первое приложение MVC.
Я написал собственный помощник по html, например
namespace MyNamespace.Web.Helpers
{
public static class HtmlExtensions
{
public static string RenderHeaderImages(this HtmlHelper html)
{
StringBuilder bldr = new StringBuilder();
List<string> files = (List<string>)HttpContext.Current.Application["HeaderImages"];
bldr.AppendLine("<table><tr>");
foreach (string file in files)
{
bldr.AppendLine(string.Format("<td><img class=\"headerImage\" src=\"{0}/Content/Images/Header/{1}\", alt=\"{2}\" /></td>"
, HtmlExtensions.GetAppPath(""), file, file));
}
bldr.AppendLine("</table></tr>");
return bldr.ToString();
}
public static string GetAppPath(this HtmlHelper html)
{
return HtmlExtensions.GetAppPath("");
}
public static string GetAppPath(this HtmlHelper html, string arg)
{
return HtmlExtensions.GetAppPath(arg);
}
public static string GetAppPath(string arg)
{
if (HttpContext.Current.Request.ApplicationPath.ToString() == @"/")
return "http://localhost:50194" + arg;
else
return HttpContext.Current.Request.ApplicationPath.ToString() + arg;
}
}
}
Затем я попытался добавить «использование» в мое представление бритвы, а также добавить namepsace в файл views / webconfig.
@using MyNamespace.Web.Helpers
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="MyNamespace.Web.Helpers"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Но все равно помощник не работает.
И это не входит в intellisense.
Что я делаю не так?