When compiling in MVC 4, an exception occurs in the View.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.