url重定向子域 [英] url redirect subdomain

查看:72
本文介绍了url重定向子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单一来源与不同的数据库进行通信,但这里的数据库名称来自子域名,任何正文帮助我。



www://user1.example.com这里user1是子域名

推荐答案

获得这样的子域名



Get the subdomain like this

string domain = Request.Url.Authority;
string subDomain = domain.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[0];





然后您可以使用它来获取正确的连接字符串。也许调用你的连接字符串user1,这样你就可以直接从ConnectionStrings集合中获取它。如果你不知道如何配置连接字符串,谷歌asp.net get connectionsrting。



You can then use that to get the correct connection string. Maybe call your connection string "user1" so you can get it direct from the ConnectionStrings collection. Google "asp.net get connectionsrting" if you don't know how to configure connection strings.


这篇关于url重定向子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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