ASP. NET Jumpstart: Introduction to Media Share Library Starter Kit

Source: Internet
Author: User
Tags asin asin number configuration settings sql server express

Abstract:Learn how to use Microsoft ASP. NET and Microsoft Visual Studio 2005 or Microsoft Visual Web Developer 2005 Express Edition to build your own starter toolkit.

Click here to download the sample code.

Content on this page
Introduction
Media Share Library Starter Kit usage
Create the required Admin role
Create Admin user
Administrator page
Enter the project manually into the media Repository
Use Amazon Web service to input a project to the media Repository
Use personal media library
Browse and borrow projects in the main media library
Borrow and lend Project Alert
Change the status of a lending project
Summary

Introduction

Welcome to the ASP. NET Jumpstart series. Four articles in this series will guide you through the creation of the entire application (from the beginning to the end ). This article is intended for beginners or fans of Microsoft ASP. NET, but those interested in new features in ASP. NET 2.0 can also benefit from this series of articles.

ASP. NET 2.0 was first introduced in 2000 based on ASP. NET 1.0/1.1. You can get ASP. NET 2.0 (Beta 2 at the time of writing this article) from MSDN for free download and use it for any application you are currently building. Although ASP. NET 1.XIt has a considerable innovation in Building Web applications, but you will find that ASP. NET 2.0 is also innovative in making you the most efficient developer. This article focuses on how to use the new ASP. NET 2.0 feature and how to make full use of the features it provides.

This document describes the Media Share Library Starter Kit and provides relevant functions after installing the toolkit on the server. This article will help you set and install the starter kit so that you can start using it immediately. Later, the article will show you how to build the application.

Next, let's take a look at the features provided by Media Share Library Starter Kit.

Back to Top

Media Share Library Starter Kit usage

Media Share Library Starter Kit allows you to easily create an application that allows a registered user to present a Media project (such as a video/TV DVD, music CD, or book) so that other registered users can borrow it. You can browse the project Libraries Shared by groups that use the application and request to borrow a specific project from a registered project owner. Media Share Library Starter Kit is designed to provide you with a framework to quickly organize a collection of project libraries that can be shared with more people.

This starter kit provides a series of pages that allow you to easily present and manage projects in the media repository and borrowed projects. For registered users, the start page of this starter kit contains a basic homepage and logon page. This starter kit also contains pages that allow you to view group libraries and personal libraries, as well as alert pages that alert other people's projects or your projects.

From this brief description, we can see that the Framework application provides many functions. After compiling and running the Media Share Library Starter Kit and using the application for a period of time, you will see the content shown in 1.

Figure1. Media Share Library Starter KitAlarm page

By simply modifying the provided code, you can use each page in the Media Share Library Starter Kit to build your own page. This will start the personalized Process of the Group Library Web site.

Media Share Library Starter Kit is also a good learning tool. You can view the code on every page of the generated application. You will find that it uses some of the most powerful functions of the latest ASP. NET version. Even if you are not planning to use this starter kit to generate an actual Web site, it is still a valuable resource for learning how to use ASP. NET 2.0 to create an application.

However, before learning how to use this application, let's take a look at the installation and startup of this starter kit.

Media Share Library Starter KitInitial settings

You can download the Media Share Library Starter Kit from MSDN, which is a Windows installation package file-Media Share Library. msi. Double-click the file to start a process and install the starter kit on your computer. The first screen of the Installation Wizard is 2. Note that the Media Share Library Starter Kit is only available in Visual Basic 2005.

Figure2.InstallMedia Share Library Starter Kit

After the installation is complete, you can open Visual Studio 2005 and then open the Web site in two different ways. SelectFile-> Open Web SiteSelect the File System button in the left pane to open the Web site as a File System project. This allows you to navigateC: \ Inetpub \ wwwroot \ MediaShareLibrary. Another option is to select the Local IIS button and open the Default Web Site node to navigateMediaShareLibrary. The two methods are shown in 3.

Figure3.OpenMedia Share Library Starter Kit

Open the Media Share Library Starter Kit option and you will notice that the project contains many folders and files. You can view all the created projects in Solution Explorer of Visual Studio, as shown in figure 4.

Figure4. Media Share LibrarySolution

In Figure 4, we can see that this starter kit contains a lot of content. It is actually divided into five main parts:

Root file (includingDefault. aspx,Web. configAndWeb. sitemap. The file added to the ASP. NET 2.0 list isWeb. sitemapFile, which is an XML-based Web site navigation structure definition.

App_DataFolder, which contains a Microsoft SQL Server Express Edition file (ASPNETDB. MDFAnd stores all input information in the Media Share Library.Library. mdfFile.ASPNETDB. MDFFiles are used to store all member identities and role management information used by applications.

App_ThemesFolder, which contains files that allow you to define the style (appearance) of the entire application ). This is a new feature in ASP. NET 2.0 that allows you to manage the appearance of the entire application through a central point. The file type in this folder includes a Cascading Style Sheet file (. CssAnd an ASP. NET skin file (. Skin). This new file (skin file) will be introduced later in this article.

AdminFolder, which contains a simple page that allows Admin users to manage the category used by the media repository. Then, these categories will be used when the registered users input their library projects into the system. Each project in the input media repository must have an associated category (such as DVD, XBOX, and Book ).

LibraryFolder, which contains the vast majority of applications discussed in this article.

Back to Top

Create the required Admin role

When you create a Media Share Library Starter Kit instance in Visual Studio, the first thing you need to do is compile and run the application. This starts a page containing the introduction page, as shown in Figure 5.

Figure5.Application Introduction page

When you start the application for the first time, you must create an administrator role to map one or more users to this role. How are these roles created? They are in the ApplicationGlobal. asaxFile. Check the file and you will notice thatApplication_StartThe following code is provided on the event (as shown in Listing 1 ).

List1.InGlobal. asaxFileApplication_StartCreate eventAdminRole

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)      ' Code that runs on application startup      If (Roles.Enabled) Then         If Not Roles.RoleExists("Admin") Then            Roles.CreateRole("Admin")         End If      End IfEnd Sub

From this code, you can see that,IfStatement first, check whether the role management system is enabled. If yes, checkAdminWhether the role exists in the system. By usingRolesClassRoleExists ()Method. If the result of this check isFalse, UseCreateRole ()Method To create a role.

The role in this application isAdminUsers can viewAdmin. aspxPage, while others cannot.Admin. aspxPage allows you to manage the categories that can be used in the media repository. All projects in the input media library must have an associated category.

Now that you have created the Media Share Library Starter KitAdminRole, you can close the application by closing the browser instance. Then, selectWebsite-> ASP. NET ConfigurationTo open the ASP. NET Website Administration Tool for the application. A Web-based GUI allows you to set specific configuration settings for your application. ClickSecurityTab to view a role configured for the application. 6.

Figure6.Check whether the application has been createdAdminRole

Now that you have created a role, let's take a look at how to create a user (then, we will assignAdminRole ).

Back to Top

Create Admin user

The most convenient place to create users is the application registration page (Join. aspx). You can clickJoin Today!To access this page. Registration page 7.

Figure7. Join. aspx

The registration process is divided into two steps. The first form requires that you enter the user's name and the group to which the user belongs. Click the Next button to go to the second form of the registration process. This form requires the user name, password, and email address. After that, you only need to clickCreate UserClick to register in the system.

Anyone who browses the Media Share Library application can access this page and register it on the site. This means that by default, applications are open to all users. Anyone can set themselves as users and log on to the application.

If someone wants to view the library and create his/her own library, they need to be registered users. PassLibraryFolderWeb. configFile to restrict anonymous users from using most applications. See list 2.

List2.InWeb. configFile to block Anonymous Users

<?xml version="1.0" encoding="utf-8"?><configuration  xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">    <system.Web>        <authorization>            <deny users="?" />        </authorization>    </system.Web></configuration>

Because ofWeb. configThe file is located inLibraryFolder, so any settings specified in this file are only appliedLibraryFolder. By using the element, you can use the child element and specify an anonymous user (by using the question mark as the value) to reject all anonymous (unregistered) users.

AdminA single file in the folder is also controlled in a similar way,Web. configAll users are rejected, and only registered users in the newly created Admin role are allowed, rather than anonymous users. TheWeb. configAs shown in listing 3.

List3. AdminFolderWeb. configFile

<configuration  xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">      <system.Web>        <authorization>          <allow roles="Admin" />          <deny users="*" />        </authorization>      </system.Web></configuration> 

Now you have passedJoin. aspxA new user is created in the registry form. The next step is to open the ASP. NET Web Site Administration Tool as before and navigate to the Security page. On this page, you will see a user you have created. ClickManage usersTo a page that allows you to manage the users you just created. To add a new user to the Admin role, clickEdit rolesLink. The available roles are displayed. Select the check box next to the role name to add a new user to the Admin role. 8.

Figure8.Add a userAdminRole

Now, you have created a user to use the application as the administrator. Next we will see a page that can be accessed by the administrator but cannot be accessed by other registered users.

Back to Top

Administrator page

The application has only one page for the Application administrator. You will see this page in the Admin folderDefault. aspx. As shown in the preceding figure, the Admin folder also containsWeb. configFile, which can control access to this folder and only allow users of the Admin role to access this page. If you are a registered user who has logged on to the application and tried to access this page, the system willLogin. aspxPage, and require you to provide the appropriate access creden. If you can access it, you will see a page shown in Figure 9.

Figure9.Management page

When a user inputs a new project into the media repository, he/she must specify a specific category for each project. These categories can then be used to represent projects and enable others to search for projects they intend to borrow more easily. To do this, you must dynamically display the category list.

Categories are stored in Microsoft SQL Server Express Edition files (. Mdf), This management page allows you to add, edit, or delete the category used by the application. By default, Media Share Library Starter Kit comes with three default categories (DVD, XBOX, and Book ).

Back to Top

Enter the project manually into the media Repository

If you have registered and logged on to the application, you can enter the project into the main media repository system. Projects entered into the entire library system are displayed in your personal library. The purpose is to enter the project of the media library for others to borrow for a specific period of time. For example, if you use this application in a group at work, someone may request to borrow a project in the system. After receiving the request, the project should be activated and lent to the requester for a period of time. After the project expires, the borrower returns the project to the original owner. This is an autonomous media Repository System for all accounts.

There are multiple ways to enter a project into the system-manually or using Amazon Web Services. First, let's take a look at how to manually enter the project into the system.

To manually enter a project, clickEnter New MediaLink. A page shown in 10 is displayed.

Figure10.Input new media to personal media library

SlaveEnterMedia. aspxPage, you can see that the system requires you to select a category to place the project. This list is derived from the set created by the Administrator (as shown in the previous figure ). The next item must be the ISBN or ASIN Number of the project.

Books generally use ISBN numbers, which can be found above the bar code on the back of the books. In one example, ISBN is 0764576100. Except books, other products (such as XBOX games) generally use ASIN numbers. These numbers are hard to find, because they are not listed on the actual product; however, you can usually find the product's ASIN number online (try to search on Amazon ).

In addition to the project category and ISBN/ASIN number, other content to be provided includes the project title, description, and image URL for the project. Use the default~ /Images/NoImage.gif. After entering all the project details into the form, clickEnter Into SystemButton. After clicking, the project is recorded in the SQL Express Edition file, and you are redirected to the library page.

Back to Top

Use Amazon Web service to input a project to the media Repository

Another (easy) option for inputting a project into the media repository is to use Amazon Web Service (free of charge) to fill in all required values based on the provided ISBN/ASIN number.

Step 1: AccessAmazon WebSiteAnd register an Amazon Web Service account.

Amazon allows you to request and use SOAP-based Web services or REST Web Services. This Media Share Library application uses the required Amazon data through REST.

Once registered with Amazon, a subscription ID will be provided for you.EnterMediaAmazon. aspxPage code to hide the file. In the code hidden file on the page, you can find the location where you want to place the subscription ID, as shown in Listing 4.

List4.Modify the page to useAmazonSubscriptionID

    Protected Sub Page_Load(ByVal sender As Object,      ByVal e As System.EventArgs) Handles Me.Load        XmlDataSource1.DataFile =            "http://Webservices.amazon.com/onca/xml?            Service=AWSECommerceService&            SubscriptionId=[YOUR SUBSCRIPTION ID]&            Operation=ItemLookup            &ResponseGroup=Medium            &ItemId=" & Request.QueryString("ISBN").ToString()        FormView1.DataBind()    End Sub

NoteMake sure that the URL is on one line. For the convenience of reading, it is divided into multiple lines.

To use Amazon to fill in all required values, you must first enter the ISBN/ASIN Number of the projectEnterMedia. aspxPage form. After entering the number, clickPopulate Values From Amazon InsteadButton. This will take you to another page, which displays the results collected from Amazon. 11.

Figure11.UseAmazonAutomatically obtain results

On this page (that isEnterMediaAmazon. aspxPage), first check to ensure that the information is correct, then use the provided drop-down list to select the media type, and then pressSelectButton. This will input the results to the media repository. GoMyLibrary. aspxPage, you will see this new content.

Back to Top

Use personal media library

The project entered in the system is displayed in your personal media library, which is displayed inMyLibrary. aspxPage. Projects displayed in the Personal Media Library are also displayed in the main media library, and other people are allowed to request to borrow the project.MyLibrary. aspxPage, as shown in Figure 12.

Figure12.View personal media libraries

The personal library page allows you to view the project of the input system. These items are displayed by media type, and the media type is controlled by the drop-down list at the top of the form. For example, figure 12 only shows all books of the user input system.

The personal media library will tell you all information about the project that is input to the system, including whether the project is in the lending period. If the row is in the light blue background during the lending period. For each item in the table, you can clickEditTo edit project information. You can even clickDeleteTo delete a project.

Back to Top

Browse and borrow projects in the main media library

No matter what project you enter into the main media library, you can carefully browse the main media library to request to borrow any project it contains. The main media repository displays all projects in the input system. The sample library 13 is shown.

Figure13.View the main media library

In the screenshot in Figure 13, you can see that the main media library is similar to a personal media library, but the difference is that in the main media library, you cannot edit or delete the items in the list. At the top of the page, you will see a drop-down list that allows you to filter project types. These projects are displayed in the following table. In the example in Figure 13, select the XBOX and display all the XBOX games in the system. The table displays the project title, owner, number of times the project was viewed and lent, and whether the project was in the lending status.

Click the project title to display the detailed view of the selected project. 14.

Figure14.View the detailed view of items in the media Repository

The project Details View displays the image of the selected project, whether the project is in the lending status, the project owner, description, and information (for example, the number of times the project was viewed and lent ).

From the project details view, you can clickBorrowButton to actually request to borrow a project (if available ). After you click, the system notifies you of the request and selects the owner's project. The statement also contains the date on which the project is returned to the owner (see figure 15 ).

Figure15.Borrow a project from the primary media library

Back to Top

Borrow and lend Project Alert

After logging on to the Media Share Library application, you will seeLibraryFolderDefault. aspxPage. This page displays a set of alerts about the projects you borrowed from others and a set of alerts about the projects you own. 16.

Figure16.Project expiration alert

In addition to alerts for borrowed and owned projects, there is a table at the bottom of the page that displays the latest 10 projects that have been entered into the primary media library.

Back to Top

Change the status of a lending project

After a user returns a project to the original owner, the owner marks the project as "Returned" in the system. This puts the project back into the system so that others can borrow it and removes all alarms. Therefore, the user must go to his/her personal media library page and clickLog items in catalog as returnedButton.

This directs the userReturnItems. aspxPage, you will see a list of check boxes for all items in the lending status (17 ).

Figure17.Mark the selected target as "Returned"

Then, the owner of these projects needs to check all the items that have been returned, and then click the button at the bottom of the form to change the lending status of the marked project.

Back to Top

Summary

This article describes how to set and use the Media Share Library Starter Kit. This starter kit is designed to show fans how to use ASP. NET 2.0 and how easy it is to build an ASP. NET 2.0 application.

The next article in the ASP. NET Jumpstart series will show you how to build the application (starting from the data layer ).

Wish you a pleasant programming!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.