https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/create-the-project

Download Wingtip Toys Sample Project (C#) or Download E-book (PDF)

This tutorial series will teach you the basics of building an ASP.NET Web Forms application using ASP.NET 4.5 and Microsoft Visual Studio Express 2013 for Web. A Visual Studio 2013project with C# source code is available to accompany this tutorial series.+

In this tutorial you will create, review, and run the default project in Visual Studio, which will allow you to become familiar with features of ASP.NET. Also, you will review the Visual Studio environment.

What you'll learn:

  • How to create a new Web Forms project.
  • The file structure of the Web Forms project.
  • How to run the project in Visual Studio.
  • The different features of the default Web forms application.
  • Some basics about how to use the Visual Studio environment.

The project will take a little time to create. When it's ready, open the Default.aspx page.

Creating the Project

You can switch between Design view and Source view by selecting an option at the bottom of the center window.

Design view displays ASP.NET Web pages, master pages, content pages, HTML pages, and user controls using a near-WYSIWYG view.

Source view displays the HTML markup for your Web page, which you can edit.

Tip

Understanding the ASP.NET Frameworks

ASP.NET offers four primary development frameworks:

ASP.NET Web Forms

ASP.NET MVC

ASP.NET Web Pages

ASP.NET Single Page Application

In addition to the four main development frameworks, ASP.NET also offers additional technologies that are important to be aware of and familiar with, but are not covered in this tutorial series:

  • ASP.NET Web API - A framework for building HTTP services that reach a broad range of clients, including browsers and mobile devices.
  • ASP.NET SignalR - A library that makes developing real-time web functionality easy.

Reviewing the Project

In Visual Studio, the Solution Explorer window lets you manage files for the project.

Let's take a look at the folders that have been added to your application in Solution Explorer.

The web application template adds a basic folder structure:

Visual Studio creates some initial folders and files for your project.

The first files that you will be working with later in this tutorial are the following:

Default.aspx    Typically the first page displayed when the application is run in a browser.

Site.Master       A page that allows you to create a consistent layout and use standard behavior for pages in your application.

Global.asax      An optional file that contains code for responding to application-level and session-level events raised by ASP.NET or by HTTP modules.

Web.config       The configuration data for an application.

Running the Default Web Application

The default Web application provides a rich experience based on built-in functionality and support.

Without any changes to the default Web forms project, the application is ready to run on your local Web browser.

There are three main pages in this default Web application: Default.aspx (Home), About.aspx, and Contact.aspx.

Each of these pages can be reached from the top navigation bar.

There are also two additional pages contained in the Account folder, the Register.aspx page and Login.aspx page.

These two pages allow you to use the membership capabilities of ASP.NET to create, store, and validate user credentials.

ASP.NET Web Forms Background

ASP.NET Web Forms are pages that are based on Microsoft ASP.NET technology, in which code that runs on the server dynamically generates Web page output to the browser or client device.

An ASP.NET Web Forms page automatically renders the correct browser-compliant HTML for features such as styles, layout, and so on.

Web Forms are compatible with any language supported by the .NET common language runtime, such as Microsoft Visual Basic and Microsoft Visual C#.

Also, Web Forms are built on the Microsoft .NET Framework, which provides benefits such as a managed environment, type safety, and inheritance.

When an ASP.NET Web Forms page runs, the page goes through a life cycle in which it performs a series of processing steps.

These steps include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering.

As you become more familiar with the power of ASP.NET Web Forms, it is important for you to understand the ASP.NET page life cycle so that you can write code at the appropriate life-cycle stage for the effect you intend.

When a Web server receives a request for a page, it finds the page, processes it, sends it to the browser, and then discards all page information.

If the user requests the same page again, the server repeats the entire sequence, reprocessing the page from scratch.

Put another way, a server has no memory of pages that it has processed-pages are stateless.

The ASP.NET page framework automatically handles the task of maintaining the state of your page and its controls, and it provides you with explicit ways to maintain the state of application-specific information.

Tip

  • Web Application Features in the Web Forms Application Template

The ASP.NET Web Forms Application template provides a rich set of built-in functionality. It not only provides you with a Home.aspx page, an About.aspx page, a Contact.aspx page, but also includes membership functionality that registers users and saves their credentials so that they can log in to your website. This overview provides more information about some of the features contained in the ASP.NET Web Forms Application template and how they are used in the Wingtip Toys application.

  • Membership

ASP.NET Identity stores your users' credentials in a database created by the application. When your users log in, the application validates their credentials by reading the database. Your project's Accountfolder contains the files that implement the various parts of membership: registering, logging in, changing a password, and authorizing access. Additionally, ASP.NET Web Forms supports OAuth and OpenID. These authentication enhancements allow users to log into your site using existing credentials, from such accounts as Facebook, Twitter, Windows Live, and Google.

By default, the template creates a membership database using a default database name on an instance of SQL Server Express LocalDB, the development database server that comes with Visual Studio Express 2013 for Web.

  • SQL Server Express LocalDB

SQL Server Express LocalDB is a lightweight version of SQL Server that has many programmability features of a SQL Server database. SQL Server Express LocalDB runs in user mode and has a fast, zero-configuration installation that has a short list of installation prerequisites. In Microsoft SQL Server, any database or Transact-SQL code can be moved from SQL Server Express LocalDB to SQL Server and SQL Azure without any upgrade steps. So, SQL Server Express LocalDB can be used as a developer environment for applications targeting all editions of SQL Server. SQL Server Express LocalDB enables features such as stored procedures, user-defined functions and aggregates, .NET Framework integration, spatial types and others that are not available in SQL Server Compact.

  • Master Pages

An ASP.NET master page defines a consistent appearance and behavior for all of the pages in your application. The layout of the master page merges with the content from an individual content page to produce the final page that the user sees. In the Wingtip Toys application, you modify the Site.mastermaster page so that all the pages in the Wingtip Toys website share the same distinctive logo and navigation bar.

  • HTML5

The ASP.NET Web Forms Application template supports HTML5, which is the latest version of the HTML markup language. HTML5 supports new elements and functionality that make it easier to create Web sites.

  • Modernizr

For browsers that do not support HTML5, you can use Modernizr. Modernizr is an open-source JavaScript library that can detect whether a browser supports HTML5 features, and enable them if it does not. In the ASP.NET Web Forms Application template, Modernizr is installed as a NuGet package.

  • Bootstrap

The Visual Studio 2013 project templates use Bootstrap, a layout and theming framework created by Twitter. Bootstrap uses CSS3 to provide responsive design, which means layouts can dynamically adapt to different browser window sizes. You can also use Bootstrap's theming feature to easily effect a change in the application's look and feel. By default, the ASP.NET Web Application template in Visual Studio 2013 includes Bootstrap as a NuGet package.

  • NuGet Packages

The ASP.NET Web Forms Application template includes a set of NuGet packages. These packages provide componentized functionality in the form of open source libraries and tools. There is a wide variety of packages to help you create and test your applications. Visual Studio makes it easy to add, remove, and update NuGet packages. Developers can create and add packages to NuGet as well.

When you install a package, NuGet copies files to your solution and automatically makes whatever changes are needed, such as adding references and changing the configuration associated with your Web application. If you decide to remove the library, NuGet removes files and reverses whatever changes it made in your project so that no clutter is left. NuGet is available from the Tools menu in Visual Studio.

  • jQuery

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. The jQuery JavaScript library is included in the ASP.NET Web Forms Application template as a NuGet package.

  • Unobtrusive Validation

Built-in validator controls have been configured to use unobtrusive JavaScript for client-side validation logic. This significantly reduces the amount of JavaScript rendered inline in the page markup and reduces the overall page size. Unobtrusive validation is added globally to the ASP.NET Web Forms Application template based on the setting in the <appSettings> element of the Web.config file at the root of the application.

  • Entity Framework Code First

Besides the features in the ASP.NET Web Forms Application template, the Wingtip Toys application usesEntity Framework Code First, which is a NuGet library that enables code-centric development when you work with data. Put simply, it creates the database portion of your application for you based on the code that you write. Using the Entity Framework, you retrieve and manipulate data as strongly typed objects. This lets you focus on the business logic in your application rather than the details of how data is accessed.

For additional information about the installed libraries and packages included with the ASP.NET Web Forms template, see the list of installed NuGet packages.

To do this, In Visual Studio create a new Web Forms project, select Tools -> Library Package Manager -> Manage NuGet Packages for Solution, and select Installed packages in the Manage NuGet Packages dialog box.

Touring Visual Studio

The primary windows in Visual Studio include the Solution Explorer, the Server Explorer(Database Explorer in Express), the Properties Window, the Toolbox, the Toolbar, and theDocument Window.

For more information about Visual Studio, see Visual Guide to Visual Web Developer.

Summary

In this tutorial you have created, reviewed and run the default Web Forms application.

You have reviewed the different features of the default Web forms application and learned some basics about how to use the Visual Studio environment.

In the following tutorials you'll create the data access layer.

Create the Project的更多相关文章

  1. How to create a project with Oracle Policy Modeling

    This blog is about how to create a project with Oracle Policy Modeling. You can do it successfully i ...

  2. create dll project based on the existing project

    Today, I have to create a dll project(called my.sln), the dllmain.cpp/.h/ is already in another proj ...

  3. create python project steps

    Setting Up Your First Project You don't have to manually create the structure above, many tools will ...

  4. Eclipse Maven to create Struts2 Project

    Follow the guide in this page: http://blog.csdn.net/topwqp/article/details/8882965 problem met : Des ...

  5. How to create a project with existing folder of files in Visual Studio?

    1. Select Visual Studio tool bar-> New -> Project from existing code-> continue with config ...

  6. Step by Step 設定 TFS 2012 Create Team Project 權限 - 避免 TF218017、TF250044

    基本上權限的設定和 以往的 TFS 沒有什麼太大的差別 只是這次的權限設定畫面有略作些調整,我還是一併整理一下 當我們用 TFSSetup 的帳號安裝完 TFS 2012 後 想要在自已的電腦上用自已 ...

  7. vs 2019 create new project 创建新项目

    下面的place solution and project in the same directory 不需要勾选

  8. Windows编译Nodejs时遇到 File "configure", line 313 SyntaxError: invalid syntax Failed to create vc project files. 时的解决方法

    第一次编译的时候电脑上未安装python,遂下载了python最新版本3.3.3,但是报了下面这个错误. 把python降到2.7.*的版本即可. 我这里测试2.7.6和2.7.3版本可以正常编译.

  9. Create Empty Project In Vs But Not Debug?

    问题描述 在使用VS创建一个空的项目管理,然后,添加项目.可是,这个时候,项目虽然可以运行,但是不能Debug进行调试. 解决方法 按照下面三张图像的设置即可.

随机推荐

  1. GDOI2017 再次酱油记

    Day 0 13:00 pm 啊...今天中午一点钟从ez出发,感觉吼有趣啊.出发前先大喊一声****,在书包里放一本党史,感觉玄学可以救命[滑稽] 15:00 pm 到达东莞,坐标:石龙名冠金凯悦大 ...

  2. BZOJ 3530 [SDOI2014]数数 (Trie图/AC自动机+数位DP)

    题目大意:略 裸的AC自动机+数位DP吧... 定义f[i][x][0/1]表示已经匹配到了第i位,当前位置是x,0表示没到上限,1到上限,此时数是数量 然而会出现虚拟前导零,即前几位没有数字的情况, ...

  3. 开源 PHP 项目找队友、顾问、指导、贡献者等等

    介绍站点还没做,先直接甩代码链接了 https://github.com/litphp/litphp Lit是什么? Lit是我一直在撸的个人框架,按第一次上传代码来说历史 超过4年 了,从还能支持P ...

  4. Mysql学习总结(29)——MySQL中CHAR和VARCHAR

    MySQL数据库的字符(串)类不要以为字符类型就是CHAR,CHAR和VARCHAR的区别在于CHAR是固定长度,只要你定义一个字段是CHAR(10),那么不论你存储的数据是否达到了10个字节,它都要 ...

  5. 2015 Multi-University Training Contest 4 hdu 5335 Walk Out

    Walk Out Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  6. js模拟支付宝提交表单

    弄过支付宝的程序猿可能都知道,里面有非常多地方都用到了自提交表单的方式,支付宝的接口通过请求API的形式取得server返回的表单字符串,使用out.print("表单字符串")在 ...

  7. Java之旅(二)--- ServletContext

     什么是ServletContext?  WEB容器在启动时,它会为每一个WEB应用程序都创建一个相应的ServletContext对象.它代表当前web应用.通过使用这个对象,servlet能够 ...

  8. MySql基础总结(1)

    对于MySql已经是第二次看了,这次基本的目的是将MySql系统的归纳一边,之前学MySql是将笔记写在本子上,以后不想总带着本子,所以再花点时间把笔记归纳在博客中. 下午已将安装步骤具体的写了.如今 ...

  9. View注入框架:Butterknife简单使用

    View注入框架 下载地址 1.Activity Binging 通过@Bind凝视字段,Butter Knife能够通过View的ID自己主动找到并把对应的视图布局. class ExampleAc ...

  10. bzoj1009: [HNOI2008]GT考试(kmp+矩阵乘法)

    1009: [HNOI2008]GT考试 题目:传送门 题解: 看这第一眼是不是瞬间想起组合数学??? 没错...这样想你就GG了! 其实这是一道稍有隐藏的矩阵乘法,好题! 首先我们可以简化一下题意: ...