'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' - ASP.Net MVC

后端 未结 5 852
不思量自难忘°
不思量自难忘° 2021-01-17 23:37

I\'ve been trying to run ASP.Net MVC 1.0 on one machine, but can\'t get past this. I create a new MVC project (C#). It creates all the folders, views, controllers, models

相关标签:
5条回答
  • 2021-01-17 23:58

    Just trying to rule out the obvious here, but can you make sure have this in the namespaces section of the web.config?

    <add namespace="System.Web.Mvc.Html"/>
    
    0 讨论(0)
  • 2021-01-18 00:00

    Since you are referencing it in your Code Behind (ie. Default.aspx.cs) you need to include the namespace at the top of the file.

    using System.Web.Mvc.Html;

    is the Namespace that includes the RenderPartial extension method.

    0 讨论(0)
  • 2021-01-18 00:11

    You may think this is dumb, but I just had the same problem. I had a working MVC app, running 1.0.0.0 and all of a sudden it stopped working giving me the same RenderPartial isn't in the definition. Well it turns out that while I was going crazy cleaning up my web.config, I removed this section. When I re-added it, everything worked again. I'm sure this has something to do with how the class extensions load during runtime.

    Anyway, re-adding this to my web.config worked on my machine. ;)

    <system.codedom>
        <compilers>
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                         type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
    
            <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
                         type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="OptionInfer" value="true"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
        </compilers>
    </system.codedom>
    
    0 讨论(0)
  • 2021-01-18 00:16

    Another possible problem (depending on your error string) is that the extension method is there, but that the compiler couldn't match up your parameters to the known method parameters. I ran into this using T4MVC (noob) and forgetting to add ActionNames before the name of the action I was calling.

    0 讨论(0)
  • 2021-01-18 00:18

    According to your error message, you are referencing System.Web.Mvc.HtmlHelper. I am looking at the System.Web.Mvc dll in Reflector, and it's telling me that RenderPartial resides in the namespace System.Web.Mvc.Html, not System.Web.Mvc.HtmlHelper.

    0 讨论(0)
提交回复
热议问题