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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:50:10+00:00 2026-05-18T19:50:10+00:00

I just read this blog post on Razor Templating in ASP.NET MVC 3. Put

  • 0

I just read this blog post on Razor Templating in ASP.NET MVC 3.

Put simply, i just dont get it!

That is, i don’t see why we need this (fairly) complicated code to achieve what can be done IMO easier (and neater) with @RenderPartial ?

Here’s what i don’t like:

  1. The template is stored as a Func<T,HelperResult> delegate?
  2. That template delegate is persisted in the Controller ViewData (e.g HttpContext.Current.Items)

The only “benefit” i read from that blog is that a seperate file isn’t required for templating, meaning you don’t need to re-compile etc.

But i don’t see that as a valid argument. Extra files are fine as long as the solution organization isn’t compromised.

I prefer using @RenderPartial, as i can keep my markup seperate from the master view, and i can render this both inline (render time) and with jQuery (e.g AJAX event).

Maybe i’m missing something here, but can anyone give some reasons why we should choose Razor Templating over RenderPartial to create re-usable content?

  • 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-18T19:50:11+00:00Added an answer on May 18, 2026 at 7:50 pm

    Well, you should ask the author of that post about his motivation for presenting this technique.

    It certainly illustrates what is possible in Razor. Whether you should use it is a different matter. I personally think that there are alternative techniques that are less complicated (I agree with your points about storing a Func inside of the request context).

    • There’s @RenderPartial which you already mentioned.
    • You can also use the @helper syntax (either as a local helper or a global helper)
    • You can write an html helper (and use TagBuilder to assemble the output)
    • You can write a child action
    • You can write a templated helper

    Now that I look at the above list I think MVC might provide too much choice 🙂

    Update To better illustrate how inline templates can be useful I wrote a blog post about using them to call sections with default code: Optional Razor Sections with Default Content.

    You can use it to write something like this:

    @this.RenderSection("OptionalSection", @<div>Default Content</div>) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read this blog post and it stated that: Google is now working
I just read a blog post that explains MVC with a banking analogy. I
I just read this blog post about a recipe to lazily initialize an object
I just read about SQL injection and found this function on the blog i
I read ScottGu's blog entry ( http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx ) a while back, and it seems
I've just read on a blog that the UDID will not survive iOS 5.
Just read this interesting article by Omar on his blog Linq to SQL solve
I just read this requirement on a job listing: Aware of the pitfalls of
I just read this: http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx I was under the impression that overwriting Object or
I just read this article: http://www.acunetix.com/websitesecurity/upload-forms-threat.htm which discusses some of the security risks involved

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.