【问题标题】:.Net Core SSL file This page can’t be found No webpage was found for the web address:.Net Core SSL 文件 找不到此页面 没有找到该网址的网页:
【发布时间】:2018-05-31 15:35:21
【问题描述】:

我正在尝试将 SSL 集成到我的 asp.net 核心项目中 我下载 sslforfree 文件以进行手动验证。我将验证文件上传到我的服务器

虽然路径中的服务器中有文件,但在浏览器中浏览我的网站时会出现该错误

找不到此页面 没有找到该网址的网页:

这是链接。

我的 .net 核心网站工作。只是它不显示验证文件

这是我的服务器路径文件

在 IIS 服务器中,我给出了 mime 类型 .(逗号)作为文本/纯文本 但它仍然给出错误。我该怎么办?这适用于具有 4.0 应用程序池的 .net mvc 项目,但使用 asp.net 核心应用程序池给出页面未找到错误

这是我的 startup.cs

 public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddSession();


        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default2",
                    template: "{controller=Admin}/{action=BookFastSearch}/{id?}");
            });
        }
    }

【问题讨论】:

  • 您的管道在 Startup.Configure 中是什么样的?
  • @IvanZaruba 感谢 answear。我在问题末尾添加了 startup.cs 我应该添加任何用于路径访问的命令吗?

标签: iis .net-core asp.net-core-2.0 kestrel-http-server kestrel


【解决方案1】:

默认情况下,StaticFilesMiddleware 期望所请求的文件具有扩展名并且是已知类型。您没有扩展,因此您可以添加一个自定义中间件来为这些文件提供服务,或者使用

配置默认中间件
app.UseStaticFiles(new StaticFileOptions
{
    ServeUnknownFileTypes = true
});

【讨论】:

    【解决方案2】:

    为澄清起见,您的问题通过将句点引用为逗号有点令人困惑。

    我遇到了同样的问题,因为默认情况下 IIS 不显示没有文件扩展名的文件的文件内容。我还尝试在 sslforfree.com 上通过手动方法验证我的域。

    对我有用的解决方案是,正如您提到的添加条目 Extension = "." (时期); MIME Type = 我网站的 IIS MIME 类型中的“text/plain”。当您单击网站根目录时,可以在 IIS 管理器中找到它。也许它对您不起作用,因为您输入的是逗号而不是句号。

    您可以通过在您的网站中放置一个文本文件但没有文件扩展名来测试它是否有效。如果显示文件内容,则说明设置正常,sslforfree 将能够验证您的域。

    仅供参考,我在 Windows 10 版本 1809 上使用 IIS 10。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      • 2019-11-15
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      • 2020-03-09
      • 2018-06-11
      相关资源
      最近更新 更多