A bug in MVC that razor

Source: Internet
Author: User

Specific things will not be more said, all compiled, code is a wood problem.

Results Preview page When unexpectedly tell me compile error, this is not science AH.

Take a look at the error page

Look at the problem should probably be missing}, or more than a} upside down compilation error, but compile generation completely no problem ah, no way, since the issue, it must be the final merge generated code file there is a bug

That's where the problem is, there is no way to bite the bullet check it.

1. Show try to debug run a page, found that the background is absolutely no problem. After the return view (), the Yellow pages appear. The question should be in the HTML page, so take a look at what's on the HTML page.

General HTML, even if the wrong will not affect the compilation, not to mention the use of the auto-alignment with VS, it is possible to align the code, at a glance, there should be no problem. The question should be at the beginning. Let's take a look.

section of the page code bar

@using junph.entities.eshop@{    viewbag.title = "Clearing Center";    var contactlist = (ilist<crm_usercontact>) @ViewBag. contactlist;    Crm_usercontact defaultcontact = null;    if (contactlist! = null)    {        defaultcontact = contactlist[0];}    } 

This is part of the code at the beginning of the HTML page. The back of the HTML is not posted, there is no point.

To say that is the problem of curly braces, there is only one possibility, where the nesting of curly braces may be problematic. What the hell is the problem? Try to get rid of the code of Judgment first try it.

depend on, sure enough no problem, the page is at least displayed. The problem must be here.

Razor grammatical impression that this should be no problem in writing it. As a matter of fact, there is no problem with grammar.

http://blog.csdn.net/pasic/article/details/7072340

That's weird, isn't it a bug? , then changed the wording, the judgment logic is written in a separate code block (in fact, you can directly use the ternary expression?). : To avoid this problem, the main thing here is to see what it is.

@{    if (contactlist! = null    )        {defaultcontact = contactlist[0];}    }

Preview the page again, no problem. Oh, I can only say pit Ah, unlucky met.

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.