mxmissile
mxmissile

Reputation: 11673

Broken RenderPartial After Upgrade To ASP.NET MVC2

I upgraded a MVC1 project to MVC2, now all my calls to RenderPartial are throwing

System.ArgumentNullException: Value cannot be null.

However this does works:

<% Html.RenderPartial("~/Views/Shared/LogOnUserControl.ascx"); %>

And this does not (works in MVC1):

<% Html.RenderPartial("LogOnUserControl"); %>

Did the behavior of RenderPartial change?

Upvotes: 2

Views: 1820

Answers (2)

mxmissile
mxmissile

Reputation: 11673

Bleh.... found the problem, my project was referencing MVCContrib 1.0, downloaded the latest build and referenced that instead fixed the issue.

Upvotes: 3

Nicholas Murray
Nicholas Murray

Reputation: 13533

Your call to

<% Html.RenderPartial("LogOnUserControl"); %> 

seems to be working fine otherwise you would be receiving

The partial view 'LogOnUserControl' was not found. The following locations were searched....

Considering that

When Html.RenderPartial() is called with just the name of the partial view, ASP.NET MVC will pass to the partial view the same Model and ViewData dictionary objects used by the calling view template.

and

ArgumentNullException is thrown when a method is invoked and at least one of the passed arguments is a null.

It seems like the Authentication arguments are not being passed properly to LogOnUserControl or maybe you have customised it in someway?

Upvotes: 1

Related Questions