Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:34:02+00:00 2026-05-28T01:34:02+00:00

R# is incorrectly reporting one of my MVC3 views as having an error. I

  • 0

R# is incorrectly reporting one of my MVC3 views as having an error. I have 2 layouts, each with different sections defined:

@{
    Layout = "~/Views/Shared/layout2.cshtml";
}
@section Layout2Section { @* Layout2Section is red, reported as error by R#. *@
    <span>Injected into LayoutSection2</span>
}

The view displays fine in a browser. Here is code from layout2:

@RenderSection("Layout2Section", false)
@if (!IsSectionDefined("Layout2Section"))
{
    <span>default layout2 section</span>
}

There is another layout view in ~/Views/Shared named _Layout.cshtml, the default in an MVC3 project. R# is only giving intellisense for sections in _Layout.cshtml, not layout2.cshtml. I have tried prefixing with an underscore, it does not work. If I try to define any section in layout2.cshtml that is not defined in _Layout.cshtml, R# is calling it an error. How to disable this, either to tell R# that the view is a section definer, or to get rid of the “1 file with errors” message?

Update

After derigel’s comment, I realized that the above code is not exactly what I have in my project. Specifically, the line that defines the layout uses T4MVC like so:

@{
    Layout = MVC.Shared.Views.layout;
}

If I change it to a string as in the original question, the R# error goes away. @Derigel, shall I still create a test project and post to your tracker? I just reproduced the above update in a brand new MVC3 project, after adding the T4MVC lib.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:34:02+00:00Added an answer on May 28, 2026 at 1:34 am

    @olivehour Oh, now I get it. It’s known limitation of R# – it can detect layouts only in constant string literals. Can you change T4 templates to generate constants instead of readonly fields?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have problems with Valgrind incorrectly reporting an invalid write? I've got a C
This post is incorrectly tagged 'send' since I cannot create new tags. I have
I am having a very strange problem with pound signs displaying incorrectly (or not
I have a SQL dump file consisting of incorrectly stored Cyrillic Russian ( WINDOWS-1251
I have Reporting Services set up with Forms Authentication. Our app is sitting over
I have written an extension to PHP's DateTime. On one of my sites, I
I am having an error I cannot see in the following dynamic SQL statement:
Having issues with my apps on Google Play. I have a free app which
Not sure what I am doing incorrectly here with NHibernate. I have two mapping
I have read about this error, but none of the answers seem to apply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.