ASPNetCore MVC路由让服务器处理特定的路由 [英] ASPNetCore MVC Routing Let Server Handle Specific Route

查看:177
本文介绍了ASPNetCore MVC路由让服务器处理特定的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是先前未解决的在远程Web主机上,我是用户.这是一个共享的托管环境.主机使用Plesk,我正在尝试修复AspNetCore应用程序,以允许我们加密和自动续订.

On a remote web host, I am a user. It is a shared hosting environment. The host uses Plesk, and I am trying to fix my AspNetCore application to allow Let's Encrypt's installation and automatic renewal.

我很确定AspNetCore应用程序会干扰Let's Encrypt的安装和自动更新,因为我可以轻松地创建一个空站点并安装Let's Encrypt证书,而且当我使用"quickstart" AspNetCore应用程序创建一个新站点时,安装和续订失败.

I am positive the AspNetCore application is interfering with the Let's Encrypt installation and automatic renewal, since I can create an empty site and install Let's Encrypt certs with no trouble, and when I create a fresh site with a 'quickstart' AspNetCore application, the installation and renewal fails.

我怀疑主机可能已配置为将所有请求路由到./well-known/目录到我无权访问的虚拟目录(等待主机的响应).

I suspect the host may be configured to route all requests to a ./well-known/ directory to a virtual directory that I do not have access to (waiting on a response from the host).

我已定向到或提供的所有解决方案都需要对服务器进行某种形式的管理访问,对于我而言,这不是一个解决方案.我是用户.

All of the solutions I have been directed to, or provided required some form of administrative access to the server, which is not a solution in my case. I am a user.

解决方案之一是配置路由,并让应用程序提供请求的质询密钥.由于我无权访问(可能是)别名目录,因此我无法让MVC以这种方式处理路由.

One of the solutions was to configure the route, and have the application serve the requested challenge key. Since I do not have access to the (possibly) aliased directory, I cannot have MVC handle the route in this manner.

我唯一能想到的就是以某种方式配置MVC路由,这样,当它接收到对/.well-known/的请求时,便会将请求传递给服务器.文字直通路由,以确保MVC路由不会发生干扰,不会执行任何操作,但不会停止请求,而只能让服务器处理请求.这可能吗?

The only thing I can think of, is to somehow configure MVC routes, so that when it receives a request for /.well-known/ is to pass the request on to the server. A literal pass through route, to ensure MVC routing does not interfere, does not do anything, but does not stop the request and only lets the server handle the request. Is this possible?

推荐答案

主机找到了解决方案.这是IIS的配置.

The host found the solution. This was a IIS configuration thing.

在目录./.well-known/中创建一个名为web.config

In directory ./.well-known/ create a file named web.config

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <remove name="aspNetCore" />
        </handlers>
    </system.webServer>
</configuration>

我不确定这到底是做什么的,但是看起来它排除了aspNetCore处理对该目录的任何调用.

I'm not sure exactly what this does, but it looks like it excludes aspNetCore from processing any calls to that directory.

这篇关于ASPNetCore MVC路由让服务器处理特定的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆