[英]ASP.NET Core 3.1 Routing for Razor Pages
How can I configure routing to enable different users to use their own distinct url when accessing the site?如何配置路由以允许不同用户在访问站点时使用他们自己不同的 url? I want to display their logo and other customization upon initial visit.我想在初次访问时显示他们的徽标和其他自定义设置。
Something like this:像这样的东西:
mysite.com\customer1
mysite.com\customer2
I would much prefer the following, but I believe this is not possible.我更喜欢以下内容,但我相信这是不可能的。
customer1.mysite.com
customer2.mysite.com
Is their a better way to achieve this intent?他们是实现这一意图的更好方法吗?
This isn't really a routing concern.这不是真正的路由问题。
You can have multiple subdomains pointing to the same application, and then use middleware to resolve which domain was used and set values accordingly:您可以让多个子域指向同一个应用程序,然后使用中间件来解析使用了哪个域并相应地设置值:
public class DomainResolverMiddleware
{
private readonly RequestDelegate _next;
public DomainResolverMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
var host = context.Request.Host.ToString();
// do whatever
await _next(context);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.