Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a NullReferenceException, probably only occuring in MVC5 #124

Merged
merged 1 commit into from
Aug 6, 2015
Merged

Conversation

jtheisen
Copy link
Contributor

@jtheisen jtheisen commented Aug 6, 2015

The FieldConfiguration returned from a ValidationMessageFor would throw on it's ToHtmlString call made by Razor.

The reason is that the _field member evaluates down to a call to HtmlHelper.ValidationMessageFor from System.Web.Mvc and, at least in MVC5, that returns null when there is no message to be had - which is most of the time.

I didn't research in what exactly the difference to the test project is that it makes the bug surface for me, but the MVC version difference is the one obvious suspect.

The suggested little addition of robustness fixes things for me.

… code path of ValidationMessageFor under MVC5.
robdmoore added a commit that referenced this pull request Aug 6, 2015
Fixing a NullReferenceException, probably only occuring in MVC5
@robdmoore robdmoore merged commit 41a86f7 into MRCollective:master Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants