我遇到了UrlHelper类的扩展问题,因为它们没有被拾取。到目前为止,我已经完成了以下工作:剃刀导入命名空间
1)将命名空间添加到位于Views文件夹中的web.config中的部分。我也将它们添加到主web.config中以确保。
<system.web.webPages.razor>
2)确信,在的csproj文件System.Web.Mvc参考是MVC3。我还确保包含System.Web.WebPages和System.Web.Helpers参考。
3)确保csproj ProjectTypeGuids正确。
{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
4)经过该bindingRedirect指向MVC3。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我错过了什么,因为谷歌没有提出任何不同的东西?
的代码如下(与非相关的东西剥离出来):
namespace MyNameSpace.Controllers.Extensions
{
using System.Web.Mvc;
using System.Web.Routing;
using Contracts.Entities;
using Controllers.Routing;
public static class UrlHelperExtensions
{
public static string BrowseLink(this UrlHelper urlHelper, ICategory category)
{
var routeValueDictionary = new RouteValueDictionary
{
{ "categorypath", BrowsePath.Serialize(catagory) },
{ "pagenumber", "1" }
};
return urlHelper.Action("Index", "Browse", routeValueDictionary);
}
}
}
是否在“Web.Config”中为'节添加了引用'? –
Eranga
对不起,这就是我要说的第一点,谢谢 – Chewy