ASP.NET

ASP header

ASP.NET powers websites. It generates and serves web pages in cooperation with the IIS web server.
It tests requests,
creates responses
and sends them to visitors.


ASP header

File types. ASP.NET projects have different file types. Many websites use ASPX files—these represent pages. But we also have ASHX files—these are simple handlers.

ASHX
Hypertext markup language: HTML

Write. With ASP.NET we receive a request from the web browser over the network. We then generate a response to send back. Several methods are available.

WriteWriteFileBinaryWriteWriteFile, ImageOutputStreamCompleteRequest
Razor syntax in ASP.NET

Razor syntax. With new versions of Visual Studio, we can write HTML directly inline with C# code. This makes it easier to create ASP.NET pages. Character escapes are not needed.

Razor Syntax
Hypertext transfer protocol: HTTP

HttpContext. This type is essential to ASP.NET development. It provides functionality related to the HTTP protocol. It is needed in many projects.

HttpContext.RequestTimestampLocalhost
Trace output screenshot: ASP.NET

Tracing is an easy way to build diagnostics and timings into a website. It is also easy to disable if we need more performance from a site. It is an effective diagnostic mechanism.

Trace
Print

Files. How can we handle files on the local disk on an ASP.NET website? We use File.AppendAllLines. This example implements a logging mechanism that records visits.

Files
Path type

Paths. Often the path received from the client on the network is not the same as the path on the local server. In ASP.NET we dynamically rewrite paths.

RewritePathurlMappingsServer.TransferGlobal.asaxMapPathPhysicalApplicationPath
Question

Query. When we access an ASP.NET website with a query string in the URL, such as page.aspx?test=1, the QueryString collection may be used to access the "test" value.

QueryStringParse Queries
Cache

Caching is a large part of performance. It is perhaps the largest part. We focus on improving website performance with caches—on both the client and server.

HTTP Cache HeadersSetCacheabilityCache ExpirationOutput Cache
About part

Global variables. There are several ways we can use global variables in ASP.NET websites. This can make projects much easier to develop.

Global Variables

HTTP headers are an instrumental part of the web. Client software sends requests in HTTP header format. A web server must respond with the appropriate HTTP response headers.

ContentTypeRedirect, RedirectPermanentRequest.HeadersIP AddressServerVariablesHttpWorkerRequest
Method call

With AJAX, we update pages on the client-side without needing to change the entire page. We update parts of pages. Here we tie the Page_Load event to the AJAX technique.

Page_Load
Process: gear

Configuring an ASP.NET website is frustrating. These examples span several configuration topics.
We change error outputs,
how sites are compiled,
what modules are loaded,
and more.

customErrorsIsDebuggingEnabledPipeline, httpModulesPrecompilationappSettings
Visual Studio logo

Web applications. I found that a web application is slightly more efficient than a website project. Fewer checks are needed for requests.

Web Applications
Page

Web Forms. These enable us to quickly create web pages. This feature is object-oriented. It makes web page generation code easier to maintain and improve.


Examples

Controls in Web Forms. Controls are used to represent page elements. We can insert plain text into a website using the ASP.NET Literal markup or the LiteralControl element.

asp LiteralLiteralControlHtmlLinkHtmlMetaSiteMap
Property

Properties. The ID of any element can be removed. We set the ID to null to do this. Visible enables us to use a template and remove or add elements from it without creating them in code.

Remove IDVisible
Master Page dialog in Visual Studio

Master pages separate the template from more specific content sections. We describe this separation model in more depth. We compare it to alternative models.

Master Pages
Copyright

Misc. These tutorials cover many aspects of web development. Server-side comments can be used to remove text from pages before they are sent, reducing page sizes.

Server-Side CommentsServer-Side Includes
AWS logo: Amazon Web Services

Tools. Amazon CloudFront is used to host the pages on this website. In the past, I used Fiddler to test its pages. Many sites can be served as static pages.

Amazon CloudFrontFiddler

ASP.NET is not needed for static pages. A regular C# program can generate them. But for handling requests, and reading from external data sources, ASP.NET is ideal.


C#: .NET