Wednesday, July 24, 2019
As I have mentioned before ASP.NET Core decouples the application from the infrastructure as much as possible. Therefore, you have to tell it exactly what you want in your project. In this blog post we are going to tell ASP.NET that we want to serve static html files in our application.
Here are the steps to serve static files in our ASP.NET Core application.
1. Open the "NorthwindCafe.Web" project, then click on the "Startup.cs" file in the project. You will see the following markup in the Configure method
2. Go into the Configure method, remove the existing code and type in the following code
The code above tells ASP.NET Core to use static files and also use the default files in the web server. Therefore, it will look for the index.html file in the wwwroot folder. So create an index.html file in the wwwroot folder and type in the following markup.
github Repository: https://github.com/techjunkiejh/NorthwindCafe/tree/Hour2
Here are the steps to serve static files in our ASP.NET Core application.
1. Open the "NorthwindCafe.Web" project, then click on the "Startup.cs" file in the project. You will see the following markup in the Configure method
public void Configure(IApplicationBuilder app) { app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); }
2. Go into the Configure method, remove the existing code and type in the following code
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); }
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <h1>This a static file</h1> </body> </html>
github Repository: https://github.com/techjunkiejh/NorthwindCafe/tree/Hour2
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
Aivivu - đại lý chuyên vé máy bay trong nước và quốc tế
ReplyDeletevé máy bay đi Mỹ bao nhiêu tiền
vé máy bay từ mỹ về việt nam hãng eva
đăng ký bay từ canada về Việt Nam
vé máy bay nhật bản về việt nam
Máy bay từ Hàn Quốc về Việt Nam
Vé máy bay từ Đài Loan về VN
chuyen bay danh cho chuyen gia