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 8817081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:45:54+00:00 2026-06-14T04:45:54+00:00

There are many examples out there which show how to store and retrieve virtual

  • 0

There are many examples out there which show how to store and retrieve virtual views from a file or database, but none of them show how to configure root web.config so that the application works properly, when a view’s content retrieved from a file and contains for instance @ViewBag.Title = "Some Title" line.

In this case I get CS0103: The name ‘ViewBag’ does not exist in the current context error,
just like in cases when I remove web.config from ~/Views project folder.

So, what config elements from the ~/Views/web.config to root web.config in order to fix the mentioned above error?

Is it possible to load config elements into assemby at run time?

  • 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-06-14T04:45:55+00:00Added an answer on June 14, 2026 at 4:45 am

    The problem is related to the fact that in case of a virtual view, a view whose content is retrieved from a file or database, inherits from System.Web.Mvc.ViewStartPage that contains Html and Url, but doesn’t ViewBag or Ajax properties. The virtual view is referred as follows

    public class DynamicViewsController : Controller
    {
        public ActionResult GetView()
        {
            //SomeModel model = new SomeModel() { Count = 1 };
            return View("/Virtual/VirtualViewToShow.cshtml");
        }
    }
    

    A view located in ~/Views/ folder inherits from System.Web.Mvc.WebViewPage, which has ViewBag and ViewData, and Ajax properties defined.

    The workaround to change the action method as follow

    public PartialViewResult GetView()
    {
        //SomeModel model = new SomeModel() { Count = 1 };
        return PartialView("/Virtual/VirtualViewToShow.cshtml");
    }
    

    and to add

      @{
            Layout = "~/Views/Shared/_Layout.cshtml";
       }
    

    to the text of the virtual view in order to load the layout also.
    I don’t know the reason why a virtual view inherits from System.Web.Mvc.ViewStartPage, but I’ll try to find the reason for this in another thread and will post the link when thre thread is created.

    Edited

    So a said the link to the new created thread is here

    “Show Complete Compilation Source” screenshot attachedenter image description here

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

Sidebar

Related Questions

In MonoTouch, there are many examples out there where people load NIB files like
I have a bunch of old classic ASP pages, many of which show database
I found many examples of generic repository using LINQ to SQL. However there is
I know there are many database design tool, database modeling tool. Example, ER-win ,
There were many questions about C++ template classes which contain static member variables, as
There are many errors here in SO, but this scenario I think its different.
There are many similar questions, but I didn't find one that gets straight to
This is a pretty common topic and has many answers out there. Situation :
Are there any examples out there on how to integrate HTML5Boilerplate into Symfony? The
I went over many examples of this method and still cant figure out whats

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.