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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:40:14+00:00 2026-06-01T10:40:14+00:00

A lot of my plain content is in the database, accessed by a custom

  • 0

A lot of my plain content is in the database, accessed by a custom CMS. Around the application I display simple “thank you” messages, etc. which consist of a controller action (simplified):

public ActionResult DetailsUpdated()
{
    return View();
}

and my view:

@Html.GetContent("DetailsUpdated")

I have quite a few of these and its quite annoying having a lot of view files with one-liners in. I want to be able to return that content as a View, I can do return ContentResult(ContentRepository.GetContent("KEY")); but this returns as plain-text and there is no master view rendered.

So, basically, grab the content from the DB via ContentRepository.GetContent("KEY") (returns a string) and inject it into a master view, where RenderBody() is called. I’d like to have a custom ActionResult so I can just do:

public ActionResult DetailsUpdated()
{
    return DbContentResult();
}

and then the DbContentResult ActionResult will find the content key relative to the action and controller name, go to the database and retrieve the content and display it within its master view, no physical file view needed. Is this possible?

  • 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-01T10:40:16+00:00Added an answer on June 1, 2026 at 10:40 am

    You may have one view file and refer to that view file from several actions:

    public class FooBarController : Controller { 
    
        public ViewResult Foo() { 
    
            return View("FooView", ContentRepository.GetContent("KEY"));
        }
    }
    

    In this case, you will be able to render the view whose path is ~/Views/Shared/FooView.cshtml (unless you override the default convention of course).

    Edit:

    As you indicated, you can make a custom ViewResult which does this for you:

    public class DbContentResult : ViewResult {
    
        public DbContentResult() {
    
            this.ViewName = "FooView";
            this.ViewData.Model = "Foo Model";
        }
    }
    

    Usage:

    public ActionResult Index() {
    
        return new DbContentResult();
    }
    

    Or even better, write an extension method for Controller class which integrates with DbContentResult:

    public static class ControllerExtensions {
    
        public static ViewResult DbContentResult(this Controller controller) {
    
            return new DbContentResult();
        }
    }
    

    Usage:

    public ActionResult Index() {
    
        return this.DbContentResult();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a site which is accessed entirely over HTTPS, but sometimes display external
I have a lot of plain-text content (English). I have a C# tool for
I have a lot of static JSON text content indexed in a database. Some
I have anViewA and anViewB. They're plain UIView objects with a lot of subviews.
I have an application which e-mails confirmations. The email part utilises Commons Mail API.
I'm trying to cache JSON content generated by a php script from database. However
In OS3.0 a lot of plain table views have an initially hidden search bar
I've been reading a lot about SOA's lately, but most of the content is
Our restaurant menus are pretty boring right now and display in plain text format
i'm trying to create a building navigation application similar to http://navigationapps.com/wp-content/uploads/2010/10/point-inside-2.png . I'm planning

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.