Answered by:
Is Razor only supported in .cshtml or .vbhtml files?

Question
-
User-900017823 posted
I'm learning the Razor syntax and so started with the Introduction to ASP.NET Web Programming Using the Razor Syntax (C#) here on this site. One thing I'd like to clear up, is the Razor syntax only supported in .cshtml or .vbhtml files? It's not supported in .aspx files?
Tuesday, January 28, 2014 2:45 PM
Answers
-
User281315223 posted
According to this Stack Overflow response from a former member of the ASP.NET Team (at that time) had the following response :
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
So currently and for the foreseeable future, it looks like Razor will be restricted to the mentioned .CSHTML and .VBHTML file types (outside of any third-party extensions that might implement it).
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, January 28, 2014 3:02 PM
All replies
-
User281315223 posted
According to this Stack Overflow response from a former member of the ASP.NET Team (at that time) had the following response :
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
So currently and for the foreseeable future, it looks like Razor will be restricted to the mentioned .CSHTML and .VBHTML file types (outside of any third-party extensions that might implement it).
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, January 28, 2014 3:02 PM -
User-900017823 posted
Thank you, Rion.
So, if I may, I'd like to do a follow-up question. How about other server side controls (e.g.: SqlDataSource, FileView, etc.) that are supported in .aspx pages. Are they supported in .cshtml and .vbhtml pages?
Tuesday, January 28, 2014 3:12 PM -
User281315223 posted
I don't believe that you can use Web Forms Controls at all within a Razor View (even if you configure your application to work with both environments). The fact is that Web Controls simply rely too heavily on the use of state among other things that do not exist within the Razor View engine.
Scott Hanselman has an excellent blog post that covers mixing and matching Razor and Web Forms elements that you might want to skim through as it covers some of the details of using the two within the same project.
Tuesday, January 28, 2014 4:08 PM -
User-1980594115 posted
Another link that I found interesting is:
Tuesday, January 28, 2014 5:08 PM -
User-900017823 posted
Thank you very much, Rion, you've been very helpful. I'll check out Scott Hanselman's blog entry as well.
Wednesday, January 29, 2014 9:38 AM -
User-900017823 posted
Thank you, dblaire, this is useful as well.
Wednesday, January 29, 2014 9:52 AM