CPS 353: Internet Programming

Web Servers, C# and MVC

Marcos Elugardo

Gordon College

Last Modified: 09/16/2015

Selected content adapted from material by Marty Stepp, Jessica Miller, and Victoria Kirst © 2012. Used by permission.

Agenda

Check-in

4: Server Side Basics, C# and MVC

URLs and web servers

http://server/path/file

Server-Side web programming

php jsp ruby on rails asp.net

What is C#?

asp.net

4: Server Side Basics, C# and MVC

Lifecycle of a C# web request

Hello, World!

The following contents could go into a file hello.aspx:

<%=
 "Hello, world!"
%>
Hello, world!

Viewing C# output

C# local output C# server output

Expression block example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head><title> Embedded C#</title></head>	
	<body>
		<% for ( var i = 99; i >= 1; i--) { %>
			<p> <%= i %> bottles of beer on the wall, <br />
				  <%= i %> bottles of beer. <br />
				  Take one down, pass it around, <br />
				  <%= i - 1 %> bottles of beer on the wall. </p>
		<% } %>
	</body>
</html>

Complex expression blocks

	<body>
		<% for ( int i = 1; i <= 3; i++) { %>
			<h<%= i %>>This is a level <%= i %> heading.</h<%= i %>>
		<% } %>
	</body>

This is a level 1 heading.

This is a level 2 heading.

This is a level 3 heading.

4: Server Side Basics, C# and MVC

MVC

Unit of work and repository pattern

4: Server Side Basics, C# and MVC