Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将单个ASP.NET应用程序配置为托管在多个域上?_C#_Asp.net_Web Services - Fatal编程技术网

C# 如何将单个ASP.NET应用程序配置为托管在多个域上?

C# 如何将单个ASP.NET应用程序配置为托管在多个域上?,c#,asp.net,web-services,C#,Asp.net,Web Services,我有一个网站可以调用多个web服务,该网站托管在不同的环境中,例如: https://production.domain.com https://uat.domain.com https://dev.domain.com 每个网站调用托管在同一环境中的Web服务: https://production.domain.com/rest/ https://uat.domain.com/rest/ https://dev.domain.com/rest/ 如何将我的webservice URL定义

我有一个网站可以调用多个web服务,该网站托管在不同的环境中,例如:

https://production.domain.com
https://uat.domain.com
https://dev.domain.com
每个网站调用托管在同一环境中的Web服务:

https://production.domain.com/rest/
https://uat.domain.com/rest/
https://dev.domain.com/rest/
如何将我的webservice URL定义为与应用程序所在的上下文相关?我是否需要任何IIS配置来实现这一点? 结果将是:

=>


在Web.CONFIG中有URL的多个组合,如果代码中的语句是我想做的最后一件事。

< P>如果调用的Web服务的URL之间总是存在1到1的关系,以及调用web服务的web应用程序的请求URL,那么您应该能够相对轻松地编写web服务的URL。如果您想要一个完全限定的URL,那么您可以从对网站的传入请求的开始,例如:

var uriBuilder = new UriBuilder(Request.Url);
uriBuilder.Path = "/rest";
var uriForRestService = uriBuilder.ToString();
使用的实例允许您保留协议、主机和任何自定义端口,例如,如果您使用Visual Studio/IIS Express,因此有一个test.domain.local:4321 URL风格,但如果需要,您可以自己获取和构建URL的其余部分