14

I enjoy working with ASP.NET MVC 3 using the Razor view engine, but am embarrassed to admit that not having the ability to preview the pages (.cshtml) in the Visual Studio designer negatively affects my productivity.

Is there a fundamental reason why Visual Studio won't preview Razor pages or is it simply a matter of Razor being relatively new (and released out of band), in which case we might expect preview in Visual Studio 2012?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
  • 1
    I'm commenting on my own question here, any Microsoft employees around? Notice the number of views on this question, well above the average considering the age of the question so developers are looking... – Rich Bianco Oct 01 '11 at 23:03
  • 1
    Not having this feature feels like 1 step forward.. one step back.. 20% of the time when i actually need to see the Markup i wish i could see a "preview" just so i dont have to read into the HTML to insert an @ in place of a title placeholder.. the "preview" was a serious improvement in 2008.. cant believe it was acceptable to NOT have this.. – hanzolo Oct 21 '12 at 05:58

2 Answers2

0

It is indeed just a case of Razor being so new. No doubt preview will work with Razor in a future version (who knows, perhaps a service pack to 2010 will add this). However, as @marcind points out, this is speculation on my side...

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • 7
    Commenting here since this answer is marked as the solution. In fact, it's nothing more than speculation. There are currently no plans to add a Razor designer to Visual Studio 2010. – marcind Jun 01 '11 at 18:15
  • I was re-reading this, wow this was six years ago so definitely no plans for razor preview unless it's already possible and I haven't seen it. – Rich Bianco Jun 06 '16 at 04:57
  • It's possible with RenderRazorViewToString. If you search the web, there's a small code used by many this small code can be used to make an extension in VS that would let you right click a .cshtml and have an option Preview which of course would have fake data merged with the view. I only speculate. You can even find many examples on stackoverflow already and this is just a google search result for you in a not too english version : https://gist.github.com/Draw507/330e907ddbec85e3d5c2f07f5c9a2a0e – Marc Roussel Mar 05 '19 at 20:04
  • 1
    Any news as of VS 2019? – Shimmy Weitzhandler May 05 '19 at 07:39
-1

Because there is no designer for it. You can preview it by running it.

I disagree about the productivity. In the past, with the ASPX designer, my markup was often destroyed (maybe it's better now)

Nobody knows if a designer will be there in the future. But according to this page there is a workaround available.

Rhapsody
  • 6,017
  • 2
  • 31
  • 49
  • 1
    Of course, it will increase productivity with a right designer. Can you imagine expression blend for asp.net mvc? But reality is that there is no single web design software that can do it. At this point, the only way is to open whole page in a series of browsers. That's a pain. – Tae-Sung Shin Feb 03 '13 at 12:27