{"id":4271,"date":"2020-08-07T18:03:15","date_gmt":"2020-08-07T12:33:15","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=4271"},"modified":"2020-12-02T17:24:04","modified_gmt":"2020-12-02T11:54:04","slug":"asp-net-first-program","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/asp-net-first-program\/","title":{"rendered":"ASP.NET First Program"},"content":{"rendered":"\n<p>An ASP.NET page consists of a number of server controls, including HTML controls, texts, or images. Any data that is sensitive is always stored in the hidden fields. An ASP.NET page is saved with .aspx extension. It is a server-side file. It is divided into the following core sections:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Page Directives: It set up the environment for the page to run. The @Page directive contains page-specific attributes that are used by parser and compiler. It specifies how the page should be processed.<\/li><li>Code Section: It contains the handlers and control events required by the page. The page code is precompiled and deployed in the form of binary assembly.<\/li><li>Page Layout: It contains all the interfaces, server controls, text, inline JavaScript, and HTML tags.<\/li><\/ul>\n\n\n\n<p>The first step to implement programs in ASP.NET is to create a new project in Visual Studio.&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/azure.microsoft.com\/en-in\/products\/visual-studio-code\/\" rel=\"nofollow noopener\" target=\"_blank\">Visual Studio<\/a> is an IDE (Integrated Development Environment) developed by Microsoft to create GUI applications. Form-based, as well as Web-based applications, can be designed through Visual Studio.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Let us see how to download and install Visual Studio.<\/h3>\n\n\n\n<p><strong>Step 1: <\/strong>Microsoft Visual Studio can be downloaded from the URL https:\/\/www.visualstudio.com\/downloads\/.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/_EFM-ZDY-8DfceC8RoVwVgmGlMdOoGF7xgUvFad4S3cq3c4xnJPctRoYG2z3esDvQf7bYPeBwsrPTQG3lhHH5hpHbuG2FugMPa7YTRMzdrB48U2MnDb91K6PcAp5VOdts0rqPV38eZHtZJt_XQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 2: <\/strong>You can download any of the versions (Community, Professional, or Enterprise). Here we are installing the Community version. Click on Free download. A .exe file will begin to start.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/8z8ff40ndDUvMOpbLBJBsgB64kElf_Ac5S1a3fZyfG-KdUYBKdp-GQ3ZxSWIKvkai7eL1sYCU-jtXkVA3y2aRVFc1jd6jAAmVCY5G97P1dhIJkV-_HM6ToIvShWz2vdNiu1hmO0k6eoqVlSeYQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 3: <\/strong>Run the .exe file once the download completes. Click on Continue. Visual Studio will start downloading the files.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/DvW_RtoZ3TpND_7cZfLeULX-xkx_YPL_jmL8X2gbWuAoTub3LmY2Mkfs6vesiwfz5Cgfa8kU6ujUdFoDuior-A-azLm-wlHkhNquH5EgcNHq2-fHc2hEjsWFb-MiuBgc36jLPVbWWIE3llzBkQ\" alt=\"run-vs-exe-file\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 4: <\/strong>Select the option <a href=\"https:\/\/www.h2kinfosys.com\/blog\/introduction-to-asp-net\/\">ASP.NET <\/a>and web development. .NET desktop application can also be selected if you want to develop desktop or console applications. We are selecting both the options right now and then click on Install.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Eunfbg2sG1KE_Y3RdDtf9UYg8sr9sliMU0fYOKPZIgYBl4Mo7O_CS3ZJmjkuDj_zFnJ178F6IH9yi5lqB08JNBv7y3qDCigF-D-Wnys1623cmeMC2DmV0ZcFpi8ZjdUrxWczlkHHDze9A7Gzdg\" alt=\"selecting-options-in-visual-studio\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 5: <\/strong>Visual Studio will start downloading the appropriate files based on the above selection.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/yFwb7ERVyZWHTxLv8aMS-xH8-r_4C40D3Lpg0MBr3HqFDu1hYQWI6hxaHc0D_zvEvRQtaCfuPXtVA7gYOtXX9DdmqQ5EHGRfYPhWbOaogu8i8pcHDLd3dwD59ISZnqIIym8JmR3JaPl2usqaMw\" alt=\"installation-vs-2019\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 6: <\/strong>Choose the development setting and color theme as per the choice. After selecting the required settings, click on Start Visual Studio.<\/p>\n\n\n\n<p>Visual Studio Installation completes here.<\/p>\n\n\n\n<p>&nbsp;Now we are going to implement a simple basic program to print \u201cHello World.\u201d<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Select File &gt; New &gt; Project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/GZB9T7UoPEwJtAajXTDLXLzhzjrZ3RdB1VuqukKqj2Cu8N63plJWeqtphTq-_5pj-4CrZjP3V6fsKHBBP9y4_ayKNCERtuTZCavDAP4VprizwzAcEBOWLjKrCHKN25pldV1WrTCWDcBQqKAbNQ\" alt=\"vs2-11\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 2: <\/strong>After we select the New Project, three different filters (Language, Platform, and Project Type) will appear on the page. We are not selecting any filter here. Simply click on ASP.NET Web Application (.NET Framework) and then Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/VsZURe890uvNpPKDmosmNpgUb3aUYaUH32GHN-Usc-2bZUa01VzdXSKQ7b8jRjFeyCHdAQgF-_nH2V8A0QumDjKIsrb1Jrwv_lZYdbTj1j3yy24nAvWowSHLzMM1yETqeDySvEbwOq-JKzVkHA\" alt=\"selecting-asp-net-web-application\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 3: <\/strong>Configure the project by entering the required fields such as Project Name, Solution Name, and click on Create button. The location of the project can also be modified.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Wk6sY7_R_Uz8lidBFfmxiYYfrzCZ-sKEPP6OGmjt6ZgEG9sUIHNQsZu-77mVdWqSIb7HjJYNRiGwybmYxp7J0kX8oGhWPd79kyMawS0ezdMwklTsIeooMBTfI0SOWBLA6aOtPGdugWhERB4mWg\" alt=\"project-configure-1\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 4: <\/strong>Now, we have to choose the type of application. As we are creating a web application so we will choose Empty (to ensure that we are developing a simple application), check Web Forms (it will add all the basic folders), and click on Create button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/WwoOgScpGJmP8yF2CK2wCkCEs7jSND5YodZwODHifYwBUSx6X3xiux7bxbDqojqGr_BOu4nap030wEc-JfKQ8_1n5NESF35MAIIle2wX9bKYlyDxlCO_VEQGOwx7Nv8o7EVSoOFrgdoLTvt4Bw\" alt=\"project-configure-3\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 5: <\/strong>A solution explorer will open containing a file named as Global.asax.cs that contains all the application-specific variables.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/7dIMZKU6k5Bk4c6_3VxiOJqlhPfM-MkJ_NGpcy77yQHqLzCTOQCHsR8EWUDnRemib8G1uUDFBOv-Kk0c3SWn6PwXu9fvjGbZmSKqlf5UcPVGCQH9UDFBST75VWxFg7aHSXH28lRdXgEylwi8ag\" alt=\"ASP.Net - Intro, Life Cycle &amp; Hello World Program\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 6: <\/strong>&nbsp;Now, we will need to add a web form to our project DemoApplication. For this right, click on DemoApplication &gt; Add &gt; Web Form.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/TI6pHrBkXefpz8ZZH2dGBNZGhIGmbgR3n17Jj5Qf9_IN0DLwf-Mysq1obGVUk0q_MyZ9TDSeZFRPMyep5TL4Ddu30sKI6zr-JBdADQyUbulcfbJsiSK6Fi-ykd2ny9LKHTMiigLTvaM0sPOhow\" alt=\"ASP.Net - Intro, Life Cycle &amp; Hello World Program\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 7: <\/strong>Now, a prompt box will ask for the name of the web form. Enter the name and click on OK.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/I-OLB2c1kzmoEbpAtdqniSW1SobcJKrbnbA7eqcaWsHNWJUW7WTQPxS_85ePSqTRPC0EBrIj9RM3KDvdOcdjDdF78oQbD3w_6vOiM1P4J1zQUPkpu8eVeiNwVn5K4ln-wONr6gNsjKA1GdiiTA\" alt=\"naming-web-form\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 8: <\/strong>Now, we will write a simple code to print \u201cHello World.\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/rtiOJ6sEIgYvjjPbNHyhKB3YYo1LwgkmWk2PY8iH-S2eZ5gh-SN4p3BQg2-SkwuF0izjnTAORI3M1tchdiCsIYw1uo6snYYMIjs6KrDPk-zVIUUvI2KU9c2J6GXg5tZtwCJG7I0N-VraqKiA6A\" alt=\"ASP.Net - Intro, Life Cycle &amp; Hello World Program\" title=\"\"><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html xmlns=\"www.w3.org\/1999\/xhtml\"&gt;\n&lt;head runat=\"server\"&gt;\n&lt;title&gt;&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;form id=\"form1\" runat=\"server\"&gt;\n&lt;div&gt;\n&lt;%Response. Write( \"HeIIo World\"); %&gt;\n&lt;\/div&gt;\n&lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Explanation of the code:<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>The Response object is used to revert the information back to the user.<\/li><li>Here we are using the method \u201cwrite\u201d to write the text \u201cHello World.\u201d<\/li><li>The marker tags &lt;% and %&gt; are used to add a specific code.<\/li><\/ul>\n\n\n\n<p>When we run the above program in the Visual Studio, we will get the following output.<\/p>\n\n\n\n<p><strong>OUTPUT:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Zew0BwLVlCoSTe9ToRLlfsKM48u-EZWqerE8f0G-6LEFOAT_oXhfVT_J5rnSNVrN6iNtEZ18grP6i_ZDO2tFJGD3KhcNh6THx7J00gPLLq5feu9AvKdUWcbee8mUSbf1v1v_XNjCMVtD8F-esw\" alt=\"ASP.Net - Intro, Life Cycle &amp; Hello World Program\" title=\"\"><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>An ASP.NET page consists of a number of server controls, including HTML controls, texts, or images. Any data that is sensitive is always stored in the hidden fields. An ASP.NET page is saved with .aspx extension. It is a server-side file. It is divided into the following core sections: Page Directives: It set up the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7251,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[499],"tags":[1190,1191],"class_list":["post-4271","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet-tutorials","tag-asp-net-first-program","tag-install-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=4271"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4271\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/7251"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=4271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=4271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=4271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}