You are on page 1of 15

Click to edit Master title style

ASP. Net MVC


Core
Instructor: Samra Shahzadi

1
Click to edit
Dow n l o a dMaster title style
Installation
https://visualstudio.microsoft.com/downloads/
Visual Studio Installer
Select option ASP .Net and web development

2 2
Click to edit Master
Project Creation title style

3 3
Project Name
Click to edit Master title style

4 4
Click to edit Master title style

5 5
Click to edit Master title style

6 6
Click to edit Master title style
Add a Controller

Step#1
Right click on Controller

Step#2
Select Add option

Step#3
A list will showed up
Select first option controller

7 7
Click to edit Master title style
Add a Controller

Step#1
Right click on Controller

Step#2
Select Add option

Step#3
A list will showed up
Select first option controller

8 8
Click to edit Master title style

9 9
Click to edit
Controller Master title style
Class
public class FirstController : Controller
{
public string Index()
{
return "This is my default action...";
}
public string Welcome()
{
return "This is the Welcome action method...";
}
public string Welcome(string name, int numTimes)
{
return HtmlEncoder.Default.Encode($"Hello {name}, NumTimes is:{numTimes}");
}
} 1010
Click to
HTTP edit Master title style
Request

Every public method in a controller is callable as an HTTP endpoint. 


An HTTP endpoint:
Is a targetable URL in the web application, such as https://localhost:5001/HelloWorld.
Combines:
•The protocol used: HTTPS.
•The network location of the web server, including the TCP port: localhost:5001.
•The target URI: HelloWorld.

// Requires using System.Text.Encodings.Web;


Uses HtmlEncoder.Default.Encode to protect the app from malicious input, such as through JavaScript.

1111
Click to
HTTP edit Master title style
Request

// Requires using System.Text.Encodings.Web;


• Uses HtmlEncoder.Default.Encode to protect the app
from malicious input, such as through JavaScript.

1212
Click to edit Master title style
Startup.CS

1313
ClickView
Add to edit Master title style

public IActionResult index()


{
return View();
}
• Right Click on code section and select add view.

1414
Click to edit Master title style

Thank You 

15

You might also like