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

Scaffolding MVC w/views assumes the presence of _ValidationScriptsPartial.cshtml #257

Closed
Tratcher opened this issue Jun 21, 2016 · 3 comments
Assignees

Comments

@Tratcher
Copy link
Member

Tratcher commented Jun 21, 2016

When scaffolding a new MVC controller with views using Entity Framework, the Create and Edit views reference _ValidationScriptsPartial.cshtml, which is only included in the Individual Auth template, causing this error in other templates:

InvalidOperationException: The partial view '_ValidationScriptsPartial' was not found. The following locations were searched:
 /Views/Movies/_ValidationScriptsPartial.cshtml
 /Views/Shared/_ValidationScriptsPartial.cshtml

Everything seems to work after copying the file from another project.

@barrytang
Copy link

TFS Bug#233433

@Tratcher
Copy link
Member Author

This appears to be controlled by the "Reference script libraries" checkbox on the Add Controller dialog. It's interesting that it won't generate the file if it's missing.

@jsturtevant
Copy link

For anyone that lands here in the mean time... I scaffolded a blank asp.net core project and found that the file should look like:

Add a file _ValidationScriptsPartial.cshtml to Views/Shared folder with the following:

<environment names="Development">
    <script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
    <script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js"
            asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
            asp-fallback-test="window.jQuery && window.jQuery.validator">
    </script>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
            asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
            asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive">
    </script>
</environment>

prafullbhosale added a commit that referenced this issue Aug 8, 2016
… context.

Add required files based on view generator model. Fixes #257
prafullbhosale added a commit that referenced this issue Aug 8, 2016
… context.

Add required files based on view generator model. Fixes #257
prafullbhosale added a commit that referenced this issue Aug 8, 2016
… context.

Add required files based on view generator model. Fixes #257
prafullbhosale added a commit that referenced this issue Aug 10, 2016
… context.

Add required files based on view generator model. Fixes #257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants