{"id":70285,"date":"2021-08-31T04:10:08","date_gmt":"2021-08-31T08:10:08","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/razor-web-page-model-web-application-development-in-c-net-web-applications\/"},"modified":"2025-05-11T20:17:27","modified_gmt":"2025-05-11T20:17:27","slug":"razor-web-page-model-web-application-development-in-c-net-web-applications","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=70285","title":{"rendered":"Razor, Web-page Model, Web-Application Development in C# #.Net Web Applications"},"content":{"rendered":"<p>Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=1320&amp;title=Razor,%20Web-page%20Model,%20Web-Application%20Development%20in%20C# (written long back)<\/p>\n<p><strong>Razor, Web-page Model, Web-Application Development in C#<\/strong><\/p>\n<ul>\n<li> Razor:a markup syntax to add server side code into ASP.net pages<\/li>\n<li> Razor example: Current time is @DateTime.Now<\/li>\n<li> Razor Code Syntax\n<pre>           \n         Single statement block\n     @{ var message = \"Hello World\"; }\n\n    Inline expression or variable\n    The message: @message\n\n    Multi-statement block\n    @{\n        var greeting = \"Hello\";\n        var currentTime = DateTime.Now;\n        var greetMessage = greeting + \" Current time is: \" + currentTime;\n    }\n    The greeting is: @greetMessage\n    <\/pre>\n<\/li>\n<li> Some Razor functions mainly used in the Layout file [can be used in other files based on the function]: RenderPage() &#8211; render the content of a page, RenderBody(), RenderSection(section) &#8211; render the content of a section named section<\/li>\n<li> using _ at the beginning of a web-page name prevents it from being browsed from browser such as _header.cshtml, _Layout.cshtml<\/li>\n<li> In ASP.net, you can hide sensitive information by using the _AppStart.cshtml file. Here, you can keep database passwords, and email passwords. You can also keep your webmail server configuration.<\/li>\n<li> _AppStart.cshtm example\n<pre>      \n                  @{\n            WebMail.SmtpServer = \"smtp.bizmail.yahoo.com\";\n            WebMail.EnableSsl = true;\n            WebMail.UserName = \"sayed@justetc.net\";\n            WebMail.Password = \"password\";\n            WebMail.From = \"sayed@justetc.net\";\n        }\n            <\/pre>\n<\/li>\n<li> Some folders as used in ASP.net web applications: App_Data &#8211; to keep database files, Images &#8211; image files, Scripts &#8211; JavaScript files for example, Shared &#8211; common files such as CSS files<\/li>\n<li> In a file path, ~ is used to indicate the virtual root folder.<\/li>\n<li> Server.MapPath, can convert a virtual path to a physical path<\/li>\n<li> @Href(cssPath), here cssPath is a variable for a path. You can use Href(cssPath) for the value of href attributes<\/li>\n<li> Page object methods: href (builds a url), RenderBody(), RenderPage(page), RenderSection(section), Write (object) &#8211; HTML Encoded string, WriteLiteral &#8211; No HTML encoding<\/li>\n<li> Page object properties: isPost, Layout, Page, Request, Server<\/li>\n<li> You can add properties to the Page object such as Page.Title; here Title is your own variable [not built in]<\/li>\n<li> Read from a physical file: File.ReadAllLines(filePath). You may want to use var filePath = Server.MapPath(&#8220;~\/file.txt&#8221;);, to get the physical path from a virtual path<\/li>\n<li> File.ReadAllLines(filePath), can also be used to read excel csv files [comma delimited]<\/li>\n<li> Some ASP.net helpers: Helpers are just components. WebGrid, Chart, WebMail, and WebImage are some common helpers<\/li>\n<li> WebGrid helper example: webGrid = new WebGrid (data); grid.getHtml(); data for example can be the rows of a database table, GetHtml () &#8211; will render the data as a HTML table.<\/li>\n<li> Chart example\n<pre>\n                @{\n                    var db = Database.Open(\"dbName\");\n                    var dbdata = db.Query(\"SELECT Name, Price FROM Product\");\n                    var myChart = new Chart(width: 600, height: 400)\n                       .AddTitle(\"Product Sales\")\n                       .DataBindTable(dataSource: dbdata, xField: \"Name\")\n                       .Write();\n            }\n\n            <\/pre>\n<\/li>\n<li> The above example will create bar chart [column chart]<\/li>\n<li> if you want a pie chart as output, use .AddSeries(chartType:&#8221;Pie&#8221; in the above example<\/li>\n<li> You can use an Array, or XML data as the data feed for the Chartff<\/li>\n<li> Sending emails: WebMail.Send(to:&#8221;xyz@xyz.com&#8221;, subject: &#8220;Email from &#8211; &#8221; + customerEmail, body: request<\/li>\n<li> Publish your web-site: Use the publish option from your IDE (Webmatrix, Visual Studio for Web)<\/li>\n<li> Manual publish: Make sure that the server side has the compatible ASP.net framework, copy all of your folders and files, copy the DLL files into the bin folder, copy SQL server DLL files, copy the database if appropriate<\/li>\n<\/ul>\n<p>From: http:\/\/sitestree.com\/?p=3720<br \/> Categories:.Net Web Applications<br \/>Tags:<br \/> Post Data:2016-07-16 10:49:27<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=1320&amp;title=Razor,%20Web-page%20Model,%20Web-Application%20Development%20in%20C# (written long back) Razor, Web-page Model, Web-Application Development in C# Razor:a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = &#8220;Hello World&#8221;; } Inline expression or variable The message: @message Multi-statement block @{ var greeting &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=70285\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1973,1917],"tags":[],"class_list":["post-70285","post","type-post","status-publish","format-standard","hentry","category-c-misc","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69884,"url":"http:\/\/bangla.sitestree.com\/?p=69884","url_meta":{"origin":70285,"position":0},"title":"Razor, Web-page Model, Web-Application Development in C# #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"Razor, Web-page Model, Web-Application Development in C# Razor: a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = \"Hello World\"; } Inline expression or variable The message: @message Multi-statement block @{ var greeting\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70283,"url":"http:\/\/bangla.sitestree.com\/?p=70283","url_meta":{"origin":70285,"position":1},"title":"Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C# #.Net Web Applications","author":"Author-Check- Article-or-Video","date":"August 31, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=1319&title=Random%20Notes%20and%20simple%20code%20on%20Developing%20Web%20Sites%20(Applications)%20in%20ASP.net%20using%20C# And sure, pretty old article.. Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C# The information below primarily apply to the web page model of web-development in C# _PageStart.cshtml runs at each page start\/open _AppStart.cshtml runs at the beginning of the application\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":20620,"url":"http:\/\/bangla.sitestree.com\/?p=20620","url_meta":{"origin":70285,"position":2},"title":"Some .Net Resources","author":"Author-Check- Article-or-Video","date":"February 24, 2021","format":false,"excerpt":"ASP.Net Webpages with Razor Syntax http:\/\/www.asp.net\/web-pages\/tutorials\/basics\/2-introduction-to-asp-net-web-programming-using-the-razor-syntax http:\/\/en.wikipedia.org\/wiki\/ASP.NET_Razor_view_engine What is Razor and Why? http:\/\/en.wikipedia.org\/wiki\/ASP.NET_Razor_view_engine \u00a0 ASP.Net Web-Application using MVC http:\/\/www.w3schools.com\/aspnet\/mvc_intro.asp \u00a0 Web Forms Application in ASP.Net http:\/\/www.w3schools.com\/aspnet\/aspnet_intro.asp \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 From: http:\/\/sitestree.com\/?p=1033 Categories:Web Development, Root, By Sayed Ahmed, Misc. ReadingTags: Post Data:2014-05-19 16:13:37","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":23134,"url":"http:\/\/bangla.sitestree.com\/?p=23134","url_meta":{"origin":70285,"position":3},"title":"Razor syntax and MVC application demo #Root #By Sayed Ahmed","author":"Author-Check- Article-or-Video","date":"March 25, 2021","format":false,"excerpt":"Razor syntax and MVC application demo [youtube http:\/\/www.youtube.com\/watch?v=Oi-isA8qdw0&w=560&h=315] From: http:\/\/sitestree.com\/?p=2185 Categories:Root, By Sayed AhmedTags: Post Data:2015-08-10 22:09:37 Shop Online: https:\/\/www.ShopForSoul.com\/ (Big Data, Cloud, Security, Machine Learning): Courses: http:\/\/Training.SitesTree.com In Bengali: http:\/\/Bangla.SaLearningSchool.com http:\/\/SitesTree.com 8112223 Canada Inc.\/JustEtc: http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) Shop Online: https:\/\/www.ShopForSoul.com\/ Medium: https:\/\/medium.com\/@SayedAhmedCanada","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69882,"url":"http:\/\/bangla.sitestree.com\/?p=69882","url_meta":{"origin":70285,"position":4},"title":"Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C# #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C# The information below primarily apply to the web page model of web-development in C# _PageStart.cshtml runs at each page start\/open _AppStart.cshtml runs at the beginning of the application Syntax to use the Layout file: @{Layout =\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10652,"url":"http:\/\/bangla.sitestree.com\/?p=10652","url_meta":{"origin":70285,"position":5},"title":"Razor syntax and MVC application demo","author":"Sayed","date":"August 10, 2015","format":false,"excerpt":"Razor syntax and MVC application demo [youtube http:\/\/www.youtube.com\/watch?v=Oi-isA8qdw0&w=560&h=315]","rel":"","context":"In &quot;Root&quot;","block_context":{"text":"Root","link":"http:\/\/bangla.sitestree.com\/?cat=1"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70285"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70285\/revisions"}],"predecessor-version":[{"id":78122,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70285\/revisions\/78122"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70285"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}