11

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 etc. All good. Then, when I hit F5, I get the following:

d:\VSCode2008\MVC\MvcApplication1\Views\Shared\Site.Master(19): error CS0117: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial'

this happens at the following line:

httpHandler.ProcessRequest(HttpContext.Current); in Default.aspx.cs

It seems when it is trying to do a RenderPartial() to render the logon partial.

I have version 3.51 of .Net framework installed. I installed version 1.0 of MVC, and the assembly clearly has RenderPartial() as extension methods of HtmlHelper.

Anyone seen anything similar? I have found some posts about similar problems with betas and RCs but the suggested fixes have not woredk.

I am loving the theory of MVC but it is not letting me play!

6 Answers 6

24

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"/>
Sign up to request clarification or add additional context in comments.

4 Comments

Yes - thanks - got that in web config (there are 2 web.configs, one at project level and one under views)
I needed to add this a using to this namespace and it fixed my error. System.Web.Mvc.Html must contain extensions to the HtmlHelper class
More specifically this can be found under system.web/pages/namespaces
This was it! I hadnt realized my web.config was munged.
8

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.

Comments

5

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>

1 Comment

aha! i just did exactly the same thing! doh!
2

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.

2 Comments

thanks Robert, I had a look and I see the same thing. I forgot to mention that when I run the project (or any asp.net web project) it complains about an unrecorgnised section in web.config - System.Codedom. I am thinking maybe my VS2008 needs updating - although I thought I installed sp1 it doesn't look like it's there.
Tried sp1 - no fix. Renistalled VS2008 - no fix. I think a re-image may be the quickest option here...
1

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.

Comments

1

If you migrated to visual studio 2017 or 2019 and your project is mvc4, go back into visual studio installer and check the mvc4 option under the "ASP.net and web development".

Solved my issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.