Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Absolut minimum of code in 1 aspx file that wakes .NET

Tags:

asp.net

iis

What would you write as an absolut minimum to write a aspx file? The purpose is to force the .net handler to run. Sometimes I want to make a short handwrited code to check the iis functionality. It's easy in older languages.

HTML
Hello World

ASP
<% Response.Write("Hello World") %>

ASP.NET
This works just fine but so clumsy - yes.

<%@ Page Language="C#" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("Hello World!");
    }
</script>

System.Environment.Version is nice, though, if also check the version. Is all this code really needed for asp.net? It isn't a code you just "hand print just for sake to check".

like image 394
Independent Avatar asked May 12 '11 08:05

Independent


People also ask

Can we write C# code in ASPX page?

yes, you can write C# in aspx page. Yes, if you want write c# code in same aspx file. First time you add new item > web form > check/uncheck place code in separate file.

How can I see the code behind ASPX?

Right-click the . aspx page, and then click View Code. The code-behind file opens in the editor.

What opens a .aspx file?

If you need to open and edit a . aspx file, then you can use Microsoft's free Visual Studio to do so. You could also open up such a file using a normal text editor.


1 Answers

The absolute minimum is, or could be construed to be:

<%@ Page Language="C#" %>

<%
    Response.Write("test");
%>
like image 136
Rob Avatar answered Nov 15 '22 08:11

Rob