Search   Articles   Dev Forums   Personalize   Favorites   Member Login   ASP.Net Hosting
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Sunday, July 20, 2008

Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 


ASP.NET Troubleshooting

   If you had difficulty with the example above, then perhaps you fell into one of the simple traps that commonly snare new ASP.NET programmers, and that can be easily rectified. In this section we'll look at a few common errors and reasons why your script might not run. If you did have problems, maybe this section will help you to identify them.

Program Not Found, or the Result of the ASP.NET isn't being Displayed, or the Browser tries to Download the File
   

You'll have this problem if you try to view the page as a local file on your hard drive, like this:

C:\BegASPNET\ch01\punctual.aspx

You'll also get this problem if you click on the file in Windows Explorer. If you have Microsoft FrontPage or Visual Studio.NET installed, then it will start up and attempt to help you to edit the code. Otherwise, your browser may display a warning message, or most likely it will ask you which application you wish to use to open up the ASPX file:

Older browsers may try to download the file:

The Problem
   This is because you're trying to access the page in a way that doesn't cause the ASP.NET page to be requested from the web server. Because you're not requesting the page through the web server, the ASP.NET code doesn't get processed – and that's why you don't get the expected results.

To call the web page through the web server and have the ASP.NET code processed, you need to reference the web server in the URL. Depending on whether you're browsing to the server across a local network, or across the Internet, the URL should look something like one of these:

http://localhost/5040/ch01/punctual.aspx
http://www.distantserver.com/5040/ch01/punctual.aspx

Page Cannot be Displayed: HTTP Error 403
   If you get a 403 error message, then it's probably because you don't have permission to execute the ASP.NET code contained within the page – notice the Execute Access Forbidden Error in the middle of the page:

As you'll recall, permissions are controlled by the properties of the virtual directory that contains the ASP.NET page. To change these properties, you'll need to start up the IIS admin snap-in in the MMC, as we described earlier in the chapter. Find the BegASP.NET virtual directory in the left pane, right-click on it and select Properties. This will bring up the BegASP Properties dialog that we met earlier in the chapter:

Here, you'll need to check that the value shown in the Execute Permissions box is "Scripts only" or "Scripts and Executables" –but definitely NOT "None".


Page Cannot Be Found: HTTP Error 404
   If you get this error message then it means that the browser has managed to connect to the web server successfully, but that the web server can't locate the page you've asked for. This could be because you've mistyped the URL at the browser prompt. In this case, we'll see a message like this:

If you get this page, then you might suspect one of the following errors:

  • A simple typing error in the URL, for example. http://localhost/5040/ch01/punctually.aspx

  • A wrong directory name, for example. http://localhost/5040/punctual.aspx instead of http://localhost/5040/ch01/punctual.aspx

  • Including a directory separator (/) after the file name, for example. http://localhost/5040/ch01/punctual.aspx/

  • Using the directory path in the URL, rather than using the alias, for example. http://chrisu//BegASPNET/ch01/punctual.aspx

  • Saving the page as .html or .htm, rather than as an .aspx, for example. http://localhost/5040/ch01/punctual.htm

  • Or as above, you've used the name of the physical directory rather than the virtual one for example. http://localhost/BegASPNET/ch01/punctual.aspx  

Of course, it may be that you've typed in the URL correctly, and you're still experiencing this error. In this case, the most likely cause is that you have used Notepad to save your file and that (when you saved the file) it used its default Save As Type setting, which is Text Documents (*.txt). This automatically appends a .txt suffix to the end of your file name. In this case, you will unwittingly have finished up with a file called punctual.aspx.txt.

To check if that is what happened, go to Windows Explorer, and view the (physical) folder that contains the file. Go to the Tools menu and select Folder Options…. Now, in the View tab, ensure that the Hide file extensions for known file types is unchecked, as shown here:

Now click OK and return to view your file in Windows Explorer. You may well see something like the following:

As you can see, Notepad has been less than honest in its dealings with you: when you thought that you had saved your file as punctual.aspx, it had inconveniently saved it as punctual.aspx.txt. Not surprisingly, your web server won't be able to find your file if it's been renamed accidentally. To correct the filename, right click on the it in the right pane above, select Rename from the dropdown menu that appears and remove the .txt at the end.


Web Page Unavailable While Off-line
   Very occasionally, you'll come across the following message box:

This happens because you've tried to request a page and you haven't currently got an active connection to the Internet. This is a misperception by the browser (unless your web server isn't the same machine as the one you're working on) – it is trying to get onto the Internet to get your page when there is no connection, and it's failing to realize that the page you've requested is present on your local machine. One way of retrieving the page is to hit the Connect button in the dialog; but that's not the most satisfactory of solutions (since you might incur call charges). Alternatively, you need to adjust the settings on your browser. In IE5/IE6, select the File menu and uncheck the Work Offline option.

This could also be caused if you're working on a network and using a proxy server to access the Internet. In this case, you need to bypass the proxy server or disable it for this page, as we described in the section Browsing to a Page on your Web Server, earlier in the chapter. Alternatively, if you're using a modem and you don't need to connect, you can correct this misperception by changing the way that IE looks for pages. To do this, select the Tools | Connections option and select Never dial a connection.


I Just Get a Blank Page
   If you see an empty page in your browser, then it probably means that you managed to save your punctual.aspx without entering any code into it, or that you didn't remember to refresh the browser.

The Page Displays the Message but not the Time
    If the web page displays the message "In Webserverland, the time is exactly " – but doesn't display the time – then you might have mistyped the code. For example, you may have mistyped the name of the control:

time.text=Hour(Now) & ":" & Minute(Now) & ":" & Second(Now)

and:

<asp:label id="hour" runat="server" />

The name of the control "hour", must match the first word in the line of ASP.NET code, otherwise the control won't be able to identify it.


I Get an Error Statement Citing Server Error
   If you get a message stating that the page cannot be displayed, and citing a server error such as:

then it means that there's an error in the ASP.NET code itself. Usually, there's additional information provided with the message. For example, you'd get this error message if you omitted the closing </script> tag on your code. To double-check that this isn't the case, use the sample punctual.aspx from the Wrox site at http://www.wrox.com.

I Have a Different Problem
   If your problem isn't covered by this description, it's worth testing some of the sample ASP.NET pages that are supplied with the QuickStart tutorials at http://www.asp.net. These should help you to check that IIS has actually installed properly. You can always uninstall and reinstall if necessary, although before you try this, rebooting the server first might help.

You can get support from http://p2p.wrox.com, which is our web site dedicated to support issues in this book. Alternatively, there are plenty of other web sites that are dedicated to ASP and ASP.NET. In fact you will find very few sites focus on just one of the two technologies. Here are just a few:

http://www.asp.net
http://www.asptoday.com
http://www.asp101.com
http://asptracker.com
http://www.15seconds.com
http://www.4guysfromrolla.com

There are lots of solutions, discussions, and tips on these pages, plus click-throughs to other related pages. Moreover, you can try the newsgroups available on www.asp.net such as aspngfreeforall.

You should now have successfully downloaded, set up and installed both IIS and ASP.NET, and got your first ASP.NET application up and running. If you've done all that, you can pat yourself on the back, make a cup of tea, and get ready to learn about some of the principles behind ASP.NET in the next chapter.


Summary
   We started the chapter with a brief introduction to ASP.NET and to dynamic web pages in general and we looked at some of the reasons why you'd want to use a server-side technology for creating web pages. We looked at some of the history behind dynamic web pages, in the form of an overview of the other technologies. This very brief introduction to ASP.NET will be expanded in the next chapter.

The bulk of the chapter though, was taken up by a description of the installation process. You must have installed IIS 5.0/5.1, MDAC 2.7 and either ASP.NET or the .NET Framework SDK to be able to progress at all with this book, so please don't be tempted to skip parts that might not have worked. We've listed plenty of resources that will help you get everything up and running, and there's rarely a problem that somebody somewhere hasn't encountered before.

The next chapter covers the software installed with ASP.NET, the .NET Framework, and will build up in much greater detail what ASP.NET does, what the .NET Framework is, and how the two work together.

Copyright and Authorship Notice

    This chapter is taken from "Beginning ASP.NET" by Chris Ullman, Ollie Cornes, Juan.T. Libre and Chris Goode, published by Wrox Press Limited in September 2001; ISBN 1861005040; copyright © Wrox Press Limited 2001; all rights reserved.

No part of this chapter may be reproduced, stored in a retrieval system or transmitted in any form or by any means -- electronic, electrostatic, mechanical, photocopying, recording or otherwise -- without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.

<<<<.....back  
DevASP.Net - Disclaimer - Privacy
Copyright © 2008 DevASP.net