Thursday, May 12, 2005

ASP.NET FAQs # 1

What platforms does ASP.NET run on?

Currently, it's supported on Windows 2000 and Windows XP. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. It runs on server and non-server editions of Windows 2000 and XP as long as IIS is installed. Microsoft originally planned to support ASP.NET on Windows NT 4.0, but had to reconsider due to time and technical constraints.

Can two different programming languages be mixed in a single ASPX file?

No. ASP.NET uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language.

Why can't I put <%@ Page Language="C " %> at the top of an ASPX file and write my server-side scripts in C ?

Because the parsers ASP.NET uses to extract code from ASPX files only understand C#, Visual Basic.NET, and JScript.NET. However, if you use code-behind to get your code out of the ASPX file and into a separately compiled source code file. You can write server-side scripts in any language supported by a .NET compiler.

Can I use code-behind with Global.asax files?

Yes. Here's a simple Global.asax file that doesn't use code-behind:

<%@ Import Namespace="System.Data" %>




Here's the equivalent file written to use code-behind:

<%@ Application Inherits="MyApp" %>


And here's the MyApp class that it references:

using System.Web;
using System.Data;

public class MyApp : HttpApplication
{
public void Application_Start ()
{
DataSet ds = new DataSet ();
ds.ReadXml ("GlobalData.xml");
Application["GlobalData"] = ds;
}
}


So that ASP.NET can find the MyApp class, compile it into a DLL (csc /t:library filename.cs) and place it in the application root's bin subdirectory.

Can you override method="post" in a
tag by writing ?
Yes.

Can an ASPX file contain more than one form marked runat="server"?
No.

Is it possible to see the code that ASP.NET generates from an ASPX file?

Yes. Enable debugging by including a <%@ Page Debug="true" %> directive in the ASPX file or a statement in Web.config. Then look for the generated CS or VB file in a subdirectory underneath \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files.


Does ASP.NET support server-side object tags?

Yes. The following tag creates an instance of a custom type named ShoppingCart and assigns it session scope (that is, it creates a unique ShoppingCart instance for each and every session created on the server):



Managed types created this way are identified by class name. Unmanaged types (COM classes) are identified by CLSID or ProgID.



How do I comment out statements in ASPX files?

<%--

--%>

Can I use custom .NET data types in a Web form?

Yes. Place the DLL containing the type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.

0 Comments:

Post a Comment

<< Home