asp.net mvc - System.Web.MVC.HtmlHelper Ambiguous Issue -


i have asp.net mvc application. inside views, can't use extension methods labelfor<>, textboxfor<>. have got error this:

(ambiguous name -- choose following:) system.web.webpages.html.htmlhelper system.web.mvc.htmlhelper

how can fix this?

edit: views/web.config:

<?xml version="1.0"?>  <configuration>   <configsections>     <sectiongroup name="system.web.webpages.razor" type="system.web.webpages.razor.configuration.razorwebsectiongroup, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">       <section name="host" type="system.web.webpages.razor.configuration.hostsection, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" />       <section name="pages" type="system.web.webpages.razor.configuration.razorpagessection, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" />     </sectiongroup>   </configsections>    <system.web.webpages.razor>     <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=5.1.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="system.web.optimization"/>       </namespaces>     </pages>   </system.web.webpages.razor>    <appsettings>     <add key="webpages:enabled" value="false" />   </appsettings>    <system.web>     <httphandlers>       <add path="*" verb="*" type="system.web.httpnotfoundhandler"/>     </httphandlers>      <!--         enabling request validation in view pages cause validation occur         after input has been processed controller. default         mvc performs request validation before controller processes input.         change behavior apply validateinputattribute         controller or action.     -->     <pages         validaterequest="false"         pageparserfiltertype="system.web.mvc.viewtypeparserfilter, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"         pagebasetype="system.web.mvc.viewpage, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"         usercontrolbasetype="system.web.mvc.viewusercontrol, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">       <controls>         <add assembly="system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" namespace="system.web.mvc" tagprefix="mvc" />       </controls>     </pages>   </system.web>    <system.webserver>     <validation validateintegratedmodeconfiguration="false" />      <handlers>       <remove name="blockviewhandler"/>       <add name="blockviewhandler" path="*" verb="*" precondition="integratedmode" type="system.web.httpnotfoundhandler" />     </handlers>   </system.webserver> </configuration> 

main web.config:

<system.web.webpages.razor>     <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=5.1.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.optimization" />         <add namespace="system.web.routing" />       </namespaces>     </pages>   </system.web.webpages.razor> 

system.web/pages/namespaces:

<system.web>     <httpruntime targetframework="4.5" />     <compilation debug="true" targetframework="4.5.1" />     <pages>       <namespaces>         <add namespace="system.web.helpers" />         <add namespace="system.web.mvc" />         <add namespace="system.web.mvc.ajax" />         <add namespace="system.web.mvc.html" />         <add namespace="system.web.routing" />         <add namespace="system.web.webpages" />         <add namespace="system.web.optimization" />       </namespaces>     </pages>   </system.web> 

i can't comment yet (under 50 reputation) add conversation looks you're referencing 4.0.0.0 , 5.1.0.0 of system.web.mvc, not sure that's causing problem make sure you've got binding redirects or change version numbers version have referenced. i've had multiple problems stemming various mvc/webpages dll versions.

<dependentassembly>   <assemblyidentity name="system.web.webpages" publickeytoken="31bf3856ad364e35" />   <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="3.0.0.0" /> </dependentassembly> <dependentassembly>   <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" />   <bindingredirect oldversion="1.0.0.0-5.1.0.0" newversion="5.1.0.0" /> </dependentassembly> 

thanks, gareth


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -