2

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?

1
  • Your first approach is actually more efficient/faster. Just a quick note. Commented Mar 31, 2010 at 19:46

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

When you are 89 years young, lol, you may forget such things. Glad you got sorted out.
1

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?

1 Comment

The LogOnUserControl has not been modified in anyway from the Create New Project defaults. This happens with all my partials by the way, not just that one. Again referencing the actual path works just fine.

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.