最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2018年02月25日 08:23:26   作者:河圖書卦  
這篇文章主要給大家介紹了關于asp.net core項目中如何使用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  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

總結

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

相關文章

最新評論

历史| 新安县| 汶上县| 民乐县| 定兴县| 张家界市| 三门峡市| 井冈山市| 太仆寺旗| 太康县| 云和县| 桐庐县| 得荣县| 依安县| 凤翔县| 鹤峰县| 康乐县| 乐平市| 合江县| 沧州市| 金湖县| 盐边县| 三都| 古交市| 那坡县| 西吉县| 阜阳市| 梓潼县| 岐山县| 类乌齐县| 平遥县| 隆化县| 馆陶县| 克拉玛依市| 肥乡县| 天津市| 霸州市| 黔东| 礼泉县| 凤凰县| 青田县|