我正在尝试将 Kendo UI MVC 包装器与 ServiceStack Razor Views 一起使用。
我按照Kendo UI 说明遵循了指示,希望它是直截了当的。
@HTML。没有在我的 cshtml 页面中显示 Kendo 扩展。
有人可以提供一些指导吗?
我按照 Atanas Korchev 的要求更新了这些部分
<compilation debug="true" targetFramework="4.5"> <!-- Service Stack Razor View Build Provider --> <buildProviders> <add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor, Version=2.1.*, Culture=neutral" /> </buildProviders> <assemblies> <add assembly="ServiceStack"/> <add assembly="ServiceStack.Razor"/> <add assembly="ServiceStack.Text" /> <add assembly="Kendo.Mvc"/> <add assembly="WebApplication1" /> <!-- MVC 3 Added at Atanas Korchev's request --> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </assemblies> </compilation>
(由于某种原因,它拒绝显示代码示例,但我也将 Mvc 命名空间添加到了正确的部分)
它现在抛出错误:
'ServiceStack.Html.HtmlHelper<dynamic>' does not contain a definition for 'Kendo' and the best extension method overload 'Kendo.Mvc.UI.HtmlHelperExtension.Kendo(System.Web.Mvc.HtmlHelper)' has some invalid arguments}
我将 @(Html.Kendo().DatePicker().Name("Birthday")) 粘贴到我的视图中并尝试编译,按照 Atanas 的请求获取此错误
我认为如果没有一些源代码更改来处理 ServiceStack 的 HtmlHemlper,解决方案是不可能的?
原始 Web.config
<?xml version="1.0"?>
<configuration>
<!-- Separate config section for each at the bottom of web.config -->
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<!-- Service Stack Razor View Build Provider -->
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor, Version=2.1.*, Culture=neutral" />
</buildProviders>
<assemblies>
<add assembly="ServiceStack"/>
<add assembly="ServiceStack.Razor"/>
<add assembly="ServiceStack.Text" />
<add assembly="Kendo.Mvc"/>
<add assembly="WebApplication1" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<!-- Register ServiceStack to listen on root path of web server -->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<appSettings>
<!-- Enables ServiceStack.Razor pages -->
<add key="webPages:Enabled" value="false" />
</appSettings>
<!-- ServiceStack.Razor Config -->
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<!-- Make these namespaces available to razor views-->
<!-- Required for ServiceStack -->
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<!-- Business -->
<add namespace="WebApplication1" />
<!-- Kendo UI MVC Wrappers -->
<add namespace="Kendo.Mvc.UI" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>