1. Trang chủ
  2. » Công Nghệ Thông Tin

BeginningASP.NET 2.0 with C# PHẦN 10 pps

84 251 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 84
Dung lượng 2,44 MB

Nội dung

Setup SQL Server needs Internet access during installation, so make sure it can access the Internet Otherwise, the installation will fail At the end of this installation, you should see the screen shown in Figure B-9, asking you to restart your machine You should oblige by clicking Restart Now By chance, you may not see this screen As a general rule, you shouldn’t restart more often than necessary, so if you’re not prompted to restart, don’t it Figure B-9 After your machine has restarted, the dialog box depicted in Figure B-10 is displayed, notifying you of a successful install (or any problems that were encountered) and reminding you to register the software within 30 days Figure B-10 10 Click Exit and you will now be able to start up both Visual Web Developer and SQL Express 653 Appendix B Web Site Folder Setup Next, set up the Websites folder with Windows Explorer, and create the folder C:\Websites\ WroxUnited (or use whichever drive is appropriate to your setup) To create a folder in Windows Explorer, select File➪New Folder and type in the name Websites IIS Setup (Optional) As we’ve already mentioned, Visual Web Developer Express comes with its own web server: the ASP.NET Development Server, nicknamed Cassini However, some of you might want to use IIS anyway Note that it isn’t possible to run two versions of the web site concurrently, one on IIS and one on the development server, because the database attaches itself to the ASP.NET Development Server and you will find you can’t run it with IIS without detaching the database first To use IIS, you must have Windows XP Professional, Windows 2000, or Windows 2003 Server installed Windows XP Home Edition comes without IIS, and it isn’t possible to install it on Home Edition if you manage to get a copy of IIS To begin the install, follow these steps: To install IIS go to the Start menu, navigate to Settings➪Control Panel, and click Add or Remove Programs From the left-hand menu of the dialog box (shown in Figure B-11), select the Add/Remove Windows Components icon This will bring up the Windows Components Wizard Figure B-11 654 Make sure the Internet Information Services option is selected, as shown in Figure B-12 Setup Figure B-12 Click Details and you can select which of the options to install (see Figure B-13) You won’t need all of the options, although you can install them separately at a later point However, you must make sure that you select the Common Files, the IIS snap-in, the Front Page Extensions, and the World Wide Web Services options, because these are necessary to work with ASP.NET 2.0 and Visual Web Developer Express Figure B-13 Click OK and make sure you have the Windows CD handy for the installation 655 Appendix B Create Alias If you choose to install IIS and want to use the Wrox United sample web site on IIS, you will need to create an alias so that IIS can recognize which application you mean and serve it accordingly The following steps walk you through creating an alias: From the Start menu, select Run Type MMC in the text box, and click OK In the MMC dialog box that appears, select File➪Add/Remove Snap In Click the Add button and select IIS Internet Information Services from the dialog box that appears, as depicted in Figure B-14 Figure B-14 Expand the Internet Information Services, as shown in Figure B-15 Under that will be your computer’s name Expand that as well as the Web Sites option Figure B-15 656 Setup Right-click Default Web Site, and select New➪Virtual Directory from the menu to start the wizard Type WroxUnited as the Virtual Directory Name as in Figure B-16 Figure B-16 Click Next and browse to C:\Websites\WroxUnited as the local path, as shown in Figure B-17 Figure B-17 Click Next and make sure the boxes are selected as shown in Figure B-18 Then click Next 657 Appendix B Figure B-18 Click Finish Close the MMC Console A save is optional, and you can supply a name if you so desire Wrox United Installation Go to www.wrox.com and search for the dedicated page for Beginning ASP.NET 2.0 with C++ (ISBN: 0470042583) When you are there, you can download the Wrox United application, which comes as a single downloadable zip file containing the database and application Download the zip file and save it to the C:\Websites\WroxUnited folder you created earlier Next, unzip this file to C:\Websites\ It will automatically put files in the WroxUnited folder for you, so be careful not to extract it to C:\Websites\WroxUnited, because you could end up with C:\Websites\WroxUnited\WroxUnited In Windows Explorer, make sure that inside your C:\WebSites\WroxUnited is an App_Data folder and that it has four files In particular, make sure that the following file names are present: ❑ WroxUnited.mdf ❑ ASPNETDB.mdf ❑ WroxUnited_log.ldf ❑ ASPNETDB_log.ldf If not, go back and try downloading the zip file again 658 Setup Network Service Enabling The last step before you can test the application is that you might need to add Write permissions to the Network Service account This will allow ASP.NET to use the database and to read data from it and write data to it, as is routinely required throughout the course of this book You can skip this step if you are using Windows Server 2003, because the Network Service account has these permissions already enabled by default If not, then you will almost certainly have to enable Write permissions first Here’s how: Go to Windows Explorer and select the C:\WebSites\WroxUnited\App_Data folder Rightclick it and select Sharing and Security Select the Security tab, shown in Figure B-19 Figure B-19 If you can’t see the Security tab, this is because you have Simple File Sharing switched on To disable it, select Tools➪Folder Options from Windows Explorer, and select the View tab Scroll to the bottom and uncheck the Use Simple File Sharing option (see Figure B-20) If you can’t see the Simple File Sharing option, this is because you have Windows XP Home Edition installed and it has Simple File Sharing switched on permanently, and you cannot change it Instead, you will have to take another course as outlined in the next section 659 Appendix B Figure B-20 Click the Add button in the Wrox United Properties dialog box and in the Select Users or Groups dialog box that appears Type NETWORK SERVICE into the text box and click Check Names NETWORK SERVICE will become underlined, as shown in Figure B-21 Figure B-21 If the machine is joined to a domain, you must select the Locations button first and pick the current machine, rather than the domain That’s because NETWORK SERVICE is an account on your machine By default, the dialog will attempt to add the domain name, rather than the machine name 660 Setup Click OK You are returned to the Wrox United Properties dialog box This time, select the new NETWORK SERVICE option Scroll down and check the box next to Write (see Figure B-22) Click Apply, and then click OK Figure B-22 This will enable your account to access the database Windows XP Home Edition Users Only If, when you come to browse for a Security tab in Windows Explorer, you can’t find one, this is because you have Windows XP Home Edition installed and you have a slightly more complex route to enable the correct permissions Apparently, Windows XP Home Edition users just aren’t allowed to have the same kind of power as their XP Professional counterparts To get around this, restart your computer in Safe Mode To this, restart your machine, and before the Windows XP logo appears, hold down the F8 key and select Safe Mode Let XP continue and then log in as Administrator You’ll receive a warning about running in Safe Mode, but click Yes anyway Locate the C:\WebSites\WroxUnited folder in Windows Explorer and right-click the App_Data folder Select Properties and select the Security tab that has now appeared Now go back to step in the previous section and follow the instructions from there on At the end, though, shut down and restart your machine in normal mode before you continue to the next step Checking the Installation with VWD and the ASP.NET Development Server After you have successfully downloaded the Wrox United zip file, unzipped it, and enabled the Network Service, you are ready to check your installation Follow these steps: 661 Appendix B Select the Start menu and navigate to All Programs Select the Visual Web Developer 2005 Express Edition Icon at the bottom of the menu VWD will open Select File➪Open Web Site, and browse to C:\Websites\WroxUnited and click Open When the web site has loaded into Solution Explorer, double-click default.aspx to open the file Press the F5 key to run the page and observe it in a browser You should see what appears in Figure B-23 in your browser Figure B-23 Checking the Installation with IIS Follow this step only if you have installed IIS and intend to use it as your main web server To open WroxUnited with IIS, start Internet Explorer and type http://localhost/WroxUnited into the Address line The web site should start and display what’s shown in Figure B-24 Please note that while Figure B-22 is seemingly identical to Figure B-21, the Address line reveals a small difference If you are running your site on ASP.NET Development Server (the free web server with VWD), you will get the following line (potentially with a different number): http://localhost:1231/WroxUnited This indicates that the web server is running on port 1231 The ASP.NET Development Server will arbitrarily assign a port number in the URL If you are running the web site on IIS, then you see the following line: http://localhost/WroxUnited 662 handling exceptions H handling exceptions, 7, 564 best practices, 579 Exception object, 565–566 global, 579–581 logging exceptions, 573–576 mailing exceptions, 576–578 raising exceptions, 578 trapping exceptions, 566–573 Wrox application, 10 hard disk requirements, 648 Hashtable collection, 299, 542 element, HTML, 64 health monitoring, maintenance, 610–617 element WebApplicationLifetimeEvent, 611 WebAuditEvent, 612 WebAuthenticationFailureAuditEvent, 612 WebAuthenticationSuccessAuditEvent, 612 WebBaseErrorEvent, 611 WebErrorEvent, 611 WebFailureAuditEvent, 612 WebHeartbeatEvent, 611 WebManagementEvent, 611 WebRequestErrorEvent, 612 WebRequestEvent, 611 WebSuccessAuditEvent, 612 WebViewStateFailureAuditEvent, 612 HelpLink property, Exception object, 565 hierarchical data source controls, 261 hierarchical data-bound controls, 261 HTML (Hypertext Markup Language)   element, 65 element, 64 attributes, 62 CSS property, 709–711 element, 64 brackets, 62 element, 63, 66 elements, 62 files, deployment and, 598 element, 64 element, 64 722 element, 63 element, 64 element, 64 overview, 62–66 rendering, 63 element, 64 element, 63 element, 63 tags, categories, 704, 709 element, 63 element, 64 element, 63 XHTML, 66–68 HTML controls, 82–83 Toolbox, 71 HTML panel, Toolbox, 18 HTTP (HyperText Transfer Protocol), 175 state, 176–177 System Web settings, 45 HTTP-GET, transmitting Web services, 431–432 HTTP-POST, transmitting Web services, 431–432 Hyperlink control, 81 I Identity, security and, 102 IDEs (Integrated Development Environments), VWD, 10 if statement, decisions, 312–315 IIS setup, 654 Wrox United installation and, 662 IMA, obtaining, 504 Imagecontrol, 81 ImageButton control, Click event and, 186 images files, deployment and, 598 index page, catalog, 464, 467, 470 IndexOf method, 293 indirect events, 193–195 inheritance, 338–343 CSS, 693 inherits, attribute, 351 inline styles, 692 InnerException property, Exception object, 565 INSERT INTO statement, new records, 269–271 Insert method, 293 INSERT statement, 264 new records, 269–271 Inserted event, SqlDataSource control, 187 installation troubleshooting, 663–664 VWD, 648–653 Wrox United, 658 Development Server and, 661 IIS and, 662 network services, 659 license files, deployment and, 598 life cycle of web service, 430 calling web services, 431 responses, 435 responses, returning, 433–435 transmitting web services, 431–433 LineNumber property, SqlException object, 566 HTML element, 64 LinkButton control, Click event and, 186 ListBox controls, 81, 208, 218 ListDictionary collection, 542 local variables, 344 VWD and, 661 Windows XP Home Edition, 661 instances, 327 instrumentation, maintenance, 610–617 int data type, 286 intermediate code, 356 internal Accessors, classes, 328 internal variables, 336–337 HTML element, 63 HTML element, 64 IsInRole( ) method, 404 ItemDataBound event DataItem property, 192 ItemIndex property, 192 ItemType property, 192 ItemIndex property, ItemDataBound event, 192 ItemType property, ItemDataBound event, 192 localOnly attribute, element, 588 logging exceptions, 573–576 logical operators, 310–311 login, e-commerce, 503 security, 103 Wrox application, Login controls, 103 Login panel, Toolbox, 18 LoggedIn event, Login control, 187 logical operators !, 310 &&, 310 ^, 310 ||, 310 login, Wrox United application, Login control, 103 VWD toolbox, 70 Login panel, Toolbox VWD, 18 LoginError event, Login control, 187 LoginStatus control, introduction, 103 LoginView control, introduction, 103 Logon controls Authenticate event, 187 LoggedIn event, 187 LoginError event, 187 long data type, 286 loops loop, 317–318 for loop, 318–319 foreach loop, 319–321 while loop, 317–318 L Label control, 81 LastIndexOf method, 293 layout accessibility, 172 best practices, 172–173 bugability, 172 efficiency, 172 learnability, 172 memorability, 172 satisfaction, 172 usability, 172 less than (

Ngày đăng: 09/08/2014, 14:20

TỪ KHÓA LIÊN QUAN