国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net core項目中如何使用html文件

2024-07-10 13:32:57
字體:
來源:轉載
供稿:網友

前言

大家應該都知道,在html">asp.net core 項目中,使用html文件一般通過使用中間件來提供服務:

打開 NuGet程序管理控制臺

輸入install-package Microsoft.aspnetcore.staticfiles 進行添加

ASP.NET Core static files middleware. Includes middleware for serving static files, directory browsing, and default files.

在Startup.cs中使用服務:

using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting;using Microsoft.AspNetCore.Http;using Microsoft.Extensions.DependencyInjection;namespace MyWeb{  public class Startup  {    // This method gets called by the runtime. Use this method to add services to the container.    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940    public void ConfigureServices(IServiceCollection services)    {      services.AddMvc();    }    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.    public void Configure(IApplicationBuilder app, IHostingEnvironment env)    {      app.UseStaticFiles();      app.UseMvc();    }  }}

在wwwroot下添加Baidu.html

<!DOCTYPE html><html><head>  <meta charset="utf-8" />  <title>Baidu</title></head><body>  <a href="http://www.baidu.com" target="_self"><em>進入百度</em></a></body></html>

修改Index.cshtml,添加訪問鏈接

@page@model MyWeb.Pages.IndexModel@{  ViewData["Title"] = "Index";}<h2>Index</h2><a href="Index2">Index2</a><a href="Baidu.html" target="_self">Baidu</a><hr /><a href="Customers">CustomersIndex</a><h1>Hello, world!</h1><h2>The time on the server is @DateTime.Now</h2>

運行MyWeb在Index首頁進行訪問

或者輸入地址http://localhost:端口號/Baidu.html

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到ASP.NET教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华蓥市| 高邑县| 大埔县| 崇礼县| 九台市| 阿拉善左旗| 康保县| 永新县| 绵阳市| 香港| 池州市| 东城区| 隆尧县| 文安县| 河曲县| 三明市| 永定县| 新安县| 北宁市| 镇宁| 文登市| 靖宇县| 荥经县| 馆陶县| 金乡县| 阿瓦提县| 榕江县| 宜川县| 长兴县| 莱阳市| 新巴尔虎右旗| 襄城县| 红桥区| 大化| 会宁县| 蓝田县| 蛟河市| 苏尼特左旗| 永济市| 高青县| 绥芬河市|