Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net-mvc

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!

like image 472
John Davies Avatar asked Nov 22 '09 21:11

John Davies


People also ask

What is HTML RenderPartial in MVC?

RenderPartial(HtmlHelper, String) Renders the specified partial view by using the specified HTML helper. RenderPartial(HtmlHelper, String, Object) Renders the specified partial view, passing it a copy of the current ViewDataDictionary object, but with the Model property set to the specified model.

What is the difference between render and RenderPartial?

render('myview') will render the file 'myview', complete with the $layout that's specified in your controller. renderPartial('myview') will render ONLY the contents for 'myview'. And you can use it with special keys to retun result in varuiable and to echo this html where you want.

What is RenderAction in MVC?

RenderAction(HtmlHelper, String) Invokes the specified child action method and renders the result inline in the parent view. RenderAction(HtmlHelper, String, Object) Invokes the specified child action method using the specified parameters and renders the result inline in the parent view.


2 Answers

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.

like image 172
Justin Avatar answered Sep 27 '22 21:09

Justin


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"/>
like image 37
dcp Avatar answered Sep 27 '22 20:09

dcp