{"id":1108,"date":"2012-10-19T04:41:30","date_gmt":"2012-10-19T04:41:30","guid":{"rendered":"http:\/\/nestor.nestasoft.fr\/?p=1108"},"modified":"2013-09-20T22:47:38","modified_gmt":"2013-09-20T22:47:38","slug":"asp-net-mvc-4-sixime-partie-razor-ou-aspx","status":"publish","type":"post","link":"https:\/\/nestasoft.fr\/?p=1108","title":{"rendered":"ASP.NET MVC 4 [Sixi\u00e8me partie] : Razor ou ASPX"},"content":{"rendered":"<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/09\/ApresCreatyionAdherent.PNG\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/09\/ApresCreatyionAdherent.PNG\" alt=\"Vue2\" width=\"600\" height=\"211\" border=\"0\" \/><\/a><\/p>\n<ol>\n<li><span style=\"color: #4f81bd;\"><a href=\"http:\/\/nestor.nestasoft.fr\/?p=1012\" target=\"_blank\"><strong>ASP.NET MVC 4 [Premi\u00e8re partie]\u00a0\u00a0 : Introduction<\/strong><\/a><\/span><\/li>\n<li><strong><span style=\"color: #4f81bd;\"><a href=\"http:\/\/nestor.nestasoft.fr\/?p=1059\" target=\"_blank\">.NET MVC 4 [Deuxi\u00e8me partie]\u00a0 : Ajout d\u2019un model<\/a><\/span> <\/strong><\/li>\n<li><span style=\"color: #4f81bd;\"><strong><a href=\"http:\/\/nestor.nestasoft.fr\/?p=1067\" target=\"_blank\">ASP.NET MVC 4 [Troisi\u00e8me partie]\u00a0 : Ajout d\u2019un contr\u00f4leur<\/a><\/strong><\/span><\/li>\n<li><span style=\"color: #4f81bd;\"><strong><a href=\"http:\/\/nestor.nestasoft.fr\/?p=1085\" target=\"_blank\">ASP.NET MVC 4 [Quatri\u00e8me partie] : Ajout d\u2019une vue<\/a><\/strong><\/span><\/li>\n<li><span style=\"color: #4f81bd;\"><strong><a href=\"http:\/\/nestor.nestasoft.fr\/?p=1085\" target=\"_blank\">ASP.NET MVC 4 [Cinqui\u00e8me partie] : Page Inspector<\/a><\/strong><\/span><\/li>\n<li><span style=\"color: #4f81bd;\"><strong>ASP.NET MVC 4 [Sixi\u00e8me partie]\u00a0\u00a0\u00a0\u00a0\u00a0 : Razor ou ASPX<\/strong><\/span><\/li>\n<li><span style=\"color: #4f81bd;\">ASP.NET MVC 4 [Septi\u00e8me partie]\u00a0\u00a0 : Conclusion<\/span><\/li>\n<\/ol>\n<p>Dans cette partie nous aborderons le th\u00e8me \u201cRazor ou ASPX\u201d.<\/p>\n<p>Je ne m\u2019attarderai pas sur ce th\u00e8me, cette partie sera br\u00e8ve.<\/p>\n<p>Razor et ASPX sont des moteurs de rendu (template).<\/p>\n<p><!--more--><\/p>\n<p>Un moteur de rendu est un module enfichable qui met en \u0153uvre un mod\u00e8le de syntaxe diff\u00e9rent d\u2019un autre (moteur de rendu). (on se gratte la t\u00eate?).<\/p>\n<p>Le moteur de rendu \u201cRAZOR\u201d simplifie le code XHTML des vues pour l\u2019insertion rapide et facile du code inline. Le principe de coder en code-behind n\u2019\u00e9tant pas le but du pattern MVC, il est possible de mettre la logique d\u2019affichage au sein de la vue.<\/p>\n<p>RAZOR a vu le jour dans ASP.NET MVC 3 et est pass\u00e9 \u00e0 sa version 2 avec la sortie de Visual Studio 2012.<\/p>\n<p><strong>Quelques points forts de RAZOR :<\/strong><\/p>\n<ul>\n<li>Compact et expressive : RAZOR r\u00e9duit fortement le nombre de caract\u00e8res, son parseur est assez puissant pour reconnaitre du code serveur dans du XHTML.<\/li>\n<li>Facile \u00e0 impl\u00e9menter : Avec ce moteur l\u2019on est plus productif.<\/li>\n<li>Ne tient pas compte de l\u2019\u00e9diteur de texte : Pas besoin d\u2019un \u00e9diteur sp\u00e9cifique.<\/li>\n<li>IntelliSense : Dans Visual Studio l\u2019on peut utiliser l\u2019intelliSense compl\u00e8te de RAZOR.<\/li>\n<\/ul>\n<p><strong>Comparaison RAZOR et ASPX<\/strong><strong><br \/>\nCas num\u00e9ro 1 :<\/strong><\/p>\n<ul>\n<ul>Code avec moteur de rendu ASPX :<\/ul>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/ASPX.PNG\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/ASPX.PNG\" alt=\"Vue2\" width=\"484\" height=\"81\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u00c9quivalent avec moteur de rendu Razor :<\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/Razor.PNG\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/Razor.PNG\" alt=\"Vue2\" width=\"442\" height=\"79\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Pour ce cas, nous comptons 15 caract\u00e8res (&lt;%: %&gt;) pour le type ASPX et 4 pour RAZOR.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Cas num\u00e9ro 2 : <\/strong><\/p>\n<p>Code avec moteur de rendu ASPX :<strong> <\/strong><\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/ASPX2.PNG\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/ASPX2.PNG\" alt=\"Vue2\" width=\"600\" height=\"320\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u00c9quivalent avec moteur de rendu Razor :<\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/Razor2.PNG\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2012\/10\/Razor2.PNG\" alt=\"Vue2\" width=\"599\" height=\"343\" border=\"0\" \/><\/a><\/p>\n<ul>Nous comptons 43 caract\u00e8res avec le type ASPX et 8 avec RAZOR.<\/ul>\n<ul>En conclusion, si je devrai faire un choix entre les deux moteurs de rendu sus-cit\u00e9es, je voterai pour RAZOR, car il est non seulement productif, mais aussi plus rapide en redu que son cousin ASPX et leur variant.<\/ul>\n<ul>Be connected!<\/ul>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1108\" class=\"pvc_stats all  \" data-element-id=\"1108\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>ASP.NET MVC 4 [Premi\u00e8re partie]\u00a0\u00a0 : Introduction .NET MVC 4 [Deuxi\u00e8me partie]\u00a0 : Ajout d\u2019un model ASP.NET MVC 4 [Troisi\u00e8me partie]\u00a0 : Ajout d\u2019un contr\u00f4leur ASP.NET MVC 4 [Quatri\u00e8me partie] : Ajout d\u2019une vue ASP.NET MVC 4 [Cinqui\u00e8me partie] : Page Inspector ASP.NET MVC 4 [Sixi\u00e8me partie]\u00a0\u00a0\u00a0\u00a0\u00a0 : Razor ou ASPX ASP.NET MVC 4 [Septi\u00e8me [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1108\" class=\"pvc_stats all  \" data-element-id=\"1108\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":1158,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1108","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1108"}],"version-history":[{"count":7,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1108\/revisions"}],"predecessor-version":[{"id":1758,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1108\/revisions\/1758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/media\/1158"}],"wp:attachment":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}