1、MVC屏蔽 HelP 页面暴露API接口

方法:找到目录下的 Areas\HelpPage\Views\Help

的Index.cshtml 注释如代码中

@using System.Web.Http
@using System.Web.Http.Controllers
@using System.Web.Http.Description
@using System.Collections.ObjectModel
@using Interface.Service.Areas.HelpPage.Models
@model Collection<ApiDescription>

@{
    ViewBag.Title = "ASP.NET Web API Help Page";

    // Group APIs by controller
    ILookup<HttpControllerDescriptor, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor);
}

<link type="text/css" href="~/Areas/HelpPage/HelpPage.css" rel="stylesheet" />
<header class="help-page">
    <div class="content-wrapper">
        <div class="float-left">
            <h1>@ViewBag.Title</h1>
        </div>
    </div>
</header>
<!-- 
<div id="body" class="help-page">
    <section class="featured">
        <div class="content-wrapper">
            <h2>Introduction</h2>
            <p>
                Provide a general description of your APIs here.
            </p>
        </div>
    </section>
    <section class="content-wrapper main-content clear-fix">
        @foreach (var group in apiGroups)
        {
            @Html.DisplayFor(m => group, "ApiGroup")
        }
    </section>
</div>
-->
View Code

2、屏蔽WEBAPI接口中的Swagger

找到IIS站点的请求筛选的Url 项,设置如下:

 

posted on 2024-09-09 15:04  EEEEEEEEEEEEEEEEEEE  阅读(17)  评论(0编辑  收藏  举报