When compiling in MVC 4, an exception occurs in the View.
Preface
During MVC compilation, no View errors will be prompted. We will prompt exceptions one by one during project release, which will be a headache when the project is large, because every release takes at least five minutes, at last, I received only one exception message. If there are too many page exceptions, for example, I recently sorted out the code and modified a lot of the underlying code. In this way, the efficiency of searching for exceptions through publishing is very low.
Solution
Reference URL: http://www.dotnetcurry.com/showarticle.aspx? ID = 698
Http://haacked.com/archive/2011/05/09/compiling-mvc-views-in-a-build-environment.aspx/
1. Right-click the project file and choose [uninstall project ].
2. Right-click the project file again and click the [edit] Option.
3. on the page that appears, find <PropertyGroup Condition = "'$ (Configuration) | $ (Platform)' = 'debug | AnyCPU '"> (each VS version may have different nodes)
Add the <MvcBuildViews> true </MvcBuildViews> attribute to the secondary node. If you use Debug compilation, add the attribute to the Debug node.
4. Drag the page to the bottom and add the following content before the last section </Project>.
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /></Target>
5. Select the project file, right-click to reload the project, and click Save.
Why does @ ViewBagMessage prompt "Conditional compilation disabled" in the MVC3 view <script> "?
@ ViewBag. Does the string output by Message forget to add single or double quotation marks?
The prompt box in the mvc controller shows that mvc4 is used as the code.
We recommend that you use ajax. click the button to go to the specified method for logical judgment and then return the parameters. The page determines Based on the returned parameters. If you can jump to js or bring up a new page, the JS prompt will be displayed.