- Create an empty ASP.NET Core Web Application
- Add a simple HTML page (e.g. HelloWorld.html)
- Try to access this HTML page from the browser
- Enable returning a static HTML page
- Use the Map method to create a simple route returning content to the client
- Return data that is sent passing a parameter to the client, e.g.
server:port/Sample3?x=Hello - Pass
x=<h1>Hello</h1>from the client and return - Pass
x=<script>alert('hacker');</script>from the client and return it - Encode the data before returned to the client
- Use the MapWhen method to create a route with a condition
- Create a HTML form and return it, like:
<form method="post" action="/Sample4">
<input type="text" id="text1" name="text1" />
<br />
<button type="submit">Submit</button>
</form>- Return the information entered by the user to the browser - in an encoded form
- Create a custom service and a concrete implementation class
- Add this service to the dependency injection container
- Create a custom controller SampleController with constructor injection
- Create another Map and use the custom controller
- Create and use a custom middleware
- Define an extension method for easy use of the middleware
- Add your own middleware to be used for each request
Questions:
- What needs to be done to return static content like HTML, CSS, images...?
- Which dependency injection framework is used with ASP.NET Core?
- What are examples for pre-defined middleware?