Detailed explanations of some classic ASP.NET issues
1. In which systems can ASP.NET run?
At present, ASP.NET can only run on Microsoft's Windows 2000, Windows XP and Windows 2003 systems, and requires the support of Microsoft Internet Information Server (IIS). Microsoft originally planned to make Windows NT4. 0 also supports ASP.NET, but Microsoft may have some technical issues or market considerations and has not yet implemented support for ASP.NET under NT.
2. Can more than one language be used in one ASPX file?
The answer will make you a little disappointed. Although Microsoft provides a common language runtime environment (CLR, Common Laguage Runtime), which achieves tight integration between multiple programming languages, allowing you to A VB object exports the objects required by C#, but only one language can be used in an ASPX file, just as you cannot use C# syntax in VB.NET.
3. What languages do the server-side scripts of ASPX files support?
Currently, ASPX files only support C#, Visual Basic.NET, Jscript.NET and J#, but if you use the code-behind (code separation) method to create an independent code file, you can use any . NET compiler supports the language to implement the function.
4. Can code-behind (code separation) technology be used in the Global.asax file?
Of course, for example:
Global.asax:
And use code-behind (code separation) technology
Global.asax: MyApp.vb: Imports System.Web Imports System.Web. Session State Public Class MyApp Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Application("online_session") = 0 End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Application.Lock() Application("online_session") = CInt(Application("online_session")) + 1 Application.UnLock() End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) Application.Lock() Application("online_session") = CInt(Application("online_session")) - 1 Application.UnLock() End Sub End Class
5. Can I See the code that an ASPX file generates in ASP.NET?
As you can see, when your ASPX file contains a command or is declared in Web.config, you can use Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP in the system directory Find the ASPX file generated under ASP.NET in .NET Files.
6. How to comment in ASPX files?
Same as the method in the ASP file.
7. Can there be more than one server-side Form tag in an ASPX file?
No
8. Can I use custom data types in Web forms
Yes, you can include custom data The DLL file of the type is placed in the BIN directory in the program root directory. ASP.NET will load the DLL file when the data type is referenced.
9. What events can I trigger in the Global.asax file?
The events triggered when the Application object is created and ended are
Application_Start
Application_End
The events triggered when the Session object is created and ended are
• Session_Start
• Session_End
Right The events triggered when the program has a request are (arranged in order of occurrence)
•Application_BeginRequest
•Application_AuthenticateRequest
•Application_AuthorizeRequest
•Application_ResolveRequestCache
•Application_AcquireRequestState
•Application_PreRequestHandler Execute
•Application_PostRequestHandlerExecute
•Application_ReleaseRequestState
•Application_UpdateRequestCache
•Application_EndRequest
The events triggered when an error occurs in a program are
•Application_Error
•Application_Disposed
10. Does the Web control support style sheets? (CSS)?
Yes. All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl. The following example defines a CSS class named Input and uses it to modify a TextBox control to display text in red 10-point Verdana type:
Supported, all Web controls inherit a property called CssClass from the base class System.Web.UI.WebControls.WebControl.
For example:
<html> <head> <style> .Input { font: 10pt verdana; color: red; } </style> </head> <body> <form runat="server"> <asp:TextBox CssClass="Input" RunAt="server" /> </form> </body> </html>
11、在ASPX文件中默认导入那些名称空间?
ASPX默认导入的名称空间可以直接引用了,使用其它的名称空间就的自行导入了。
默认名称空间
System
System.Collections
System.Collections.Specialized
System.Configuration
System.Text
System.Text.RegularExpressions
System.Web
System.Web.Caching
System.Web.Security
System.Web.SessionState
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
12、我是否可以自己创建服务器控件呢?
可以,创作您自己的 ASP.NET 服务器控件很容易。创建简单的自定义控件时,您所要做的只是定义从 System.Web.UI.Control 派生的类并重写它的 Render 方法。Render 方法采用 System.Web.UI.HtmlTextWriter 类型的参数。控件要发送到客户端的 HTML 作为字符串参数传递到 HtmlTextWriter 的 Write 方法。
例如:
服务器控件代码(简单显示字符串):Simple.vb:
Imports System Imports System.Web Imports System.Web.UI Namespace SimpleControlSamples Public Class SimpleVB : Inherits Control Protected Overrides Sub Render(Output As HtmlTextWriter) Output.Write("<h2 id="欢迎使用控件开发">欢迎使用控件开发!</h2>") End Sub End Class End Namespace
引用文件Simple.aspx:
<%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamplesVB" %> <html> <body> <form method="POST" action="Simple.aspx" runat=server> <SimpleControlSamples:SimpleVB id="MyControl" runat=server/> </form> </body> </html>
13、如何在ASP.NET程序中发送邮件呢?
在ASP.NET程序中发送邮件不再象ASP中那样需要组件的支持了,在.NET的框架基类的System.Web.Mail名称空间内包含的MailMessage和SmtpMail类可以实现这个功能。
例如:
Dim message As new Mail.MailMessage message.From = "web3@163.com" message.To = "web3@163.com" message.Subject = "测试" message.Body = "内容" Mail.SmtpMail.SmtpServer = "localhost" Mail.SmtpMail.Send(message)
14、我将如何通过ADO.NET读取数据库中的图片并显示它呢?
下面举一个从Microsoft SQL Server的PUB数据库读取图片并显示它的例子:
下面举一个从Microsoft SQL Server的PUB数据库读取图片并显示它的例子:
<%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Imaging" %> <%@ Import Namespace="System.IO" %> <script language="VB" runat="server"> Sub Page_load(Sender as Object, E as EventArgs) dim stream as new MemoryStream dim connection as SqlConnection connection=new SqlConnection("server=localhost;database=pubs;uid=sa;pwd=") try connection.Open() dim command as SqlCommand command = new SqlCommand ("select logo from pub_info where pub_id='0736'", connection) dim image as byte() image = command.ExecuteScalar () stream.Write (image, 0, image.Length) dim imgbitmap as bitmap imgbitmap = new Bitmap (stream) Response.ContentType = "image/gif" imgbitmap.Save (Response.OutputStream, ImageFormat.Gif) Finally connection.Close() stream.Clse() End Try End Sub </script>
The above is the detailed content of Detailed explanations of some classic ASP.NET issues. For more information, please follow other related articles on the PHP Chinese website!

C# and .NET provide powerful features and an efficient development environment. 1) C# is a modern, object-oriented programming language that combines the power of C and the simplicity of Java. 2) The .NET framework is a platform for building and running applications, supporting multiple programming languages. 3) Classes and objects in C# are the core of object-oriented programming. Classes define data and behaviors, and objects are instances of classes. 4) The garbage collection mechanism of .NET automatically manages memory to simplify the work of developers. 5) C# and .NET provide powerful file operation functions, supporting synchronous and asynchronous programming. 6) Common errors can be solved through debugger, logging and exception handling. 7) Performance optimization and best practices include using StringBuild

.NETFramework is a cross-language, cross-platform development platform that provides a consistent programming model and a powerful runtime environment. 1) It consists of CLR and FCL, which manages memory and threads, and FCL provides pre-built functions. 2) Examples of usage include reading files and LINQ queries. 3) Common errors involve unhandled exceptions and memory leaks, and need to be resolved using debugging tools. 4) Performance optimization can be achieved through asynchronous programming and caching, and maintaining code readability and maintainability is the key.

Reasons for C#.NET to remain lasting attractive include its excellent performance, rich ecosystem, strong community support and cross-platform development capabilities. 1) Excellent performance and is suitable for enterprise-level application and game development; 2) The .NET framework provides a wide range of class libraries and tools to support a variety of development fields; 3) It has an active developer community and rich learning resources; 4) .NETCore realizes cross-platform development and expands application scenarios.

Design patterns in C#.NET include Singleton patterns and dependency injection. 1.Singleton mode ensures that there is only one instance of the class, which is suitable for scenarios where global access points are required, but attention should be paid to thread safety and abuse issues. 2. Dependency injection improves code flexibility and testability by injecting dependencies. It is often used for constructor injection, but it is necessary to avoid excessive use to increase complexity.

C#.NET is widely used in the modern world in the fields of game development, financial services, the Internet of Things and cloud computing. 1) In game development, use C# to program through the Unity engine. 2) In the field of financial services, C#.NET is used to develop high-performance trading systems and data analysis tools. 3) In terms of IoT and cloud computing, C#.NET provides support through Azure services to develop device control logic and data processing.

.NETFrameworkisWindows-centric,while.NETCore/5/6supportscross-platformdevelopment.1).NETFramework,since2002,isidealforWindowsapplicationsbutlimitedincross-platformcapabilities.2).NETCore,from2016,anditsevolutions(.NET5/6)offerbetterperformance,cross-

The C#.NET developer community provides rich resources and support, including: 1. Microsoft's official documents, 2. Community forums such as StackOverflow and Reddit, and 3. Open source projects on GitHub. These resources help developers improve their programming skills from basic learning to advanced applications.

The advantages of C#.NET include: 1) Language features, such as asynchronous programming simplifies development; 2) Performance and reliability, improving efficiency through JIT compilation and garbage collection mechanisms; 3) Cross-platform support, .NETCore expands application scenarios; 4) A wide range of practical applications, with outstanding performance from the Web to desktop and game development.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
