0

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

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

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

这是链接。

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

这是我的服务器路径文件

在此处输入图像描述

在 IIS 服务器中,我将 mime 类型 .(comma) 作为文本/纯文本,但它仍然给出错误。我该怎么办?这适用于具有 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?}");
            });
        }
    }
4

2 回答 2

3

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

app.UseStaticFiles(new StaticFileOptions
{
    ServeUnknownFileTypes = true
});
于 2017-12-18T14:45:35.747 回答
1

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

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

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

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

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

于 2019-02-20T04:29:08.520 回答