我们为我们的客户建立了WCF服务,并部署了dll。一切都很完美,但我们被告知必须更改WCF的URL。
假设,我们当前的WCF URL如下所示
https://xxx.xxxxx.xxx/EGov/PostBox.svc现在,他们想让我们把那个URL更改为
https://xxx.xxxxx.xxx/EGov/TransferService.svc很容易将文件名从PostBox.svc更改为TransferService.svc,但是我们已经为我们的100个客户做到了这一点,这是不可能的。所以,我们想知道我们是否可以从配置文件中重写URL。
如果我们可以从配置文件中重写URL,那么我们将通过电子邮件将配置文件发送给每个客户,并将其放入正确的文件夹中。
我希望我把我的问题说清楚了。
发布于 2014-12-26 11:04:21
不确定这是否对您有帮助,但我有类似的情况,我必须重写URL(对我来说,我不需要向用户显示.svc文件名。
public class Route : IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.BeginRequest += delegate
{
//URL Rewriting
//---To remove the .svc extension service file name from URL----
HttpContext cxt = HttpContext.Current;
string path = cxt.Request.AppRelativeCurrentExecutionFilePath;
{
cxt.RewritePath(path.Insert(1, "/ReportingService.svc"), false);
}
};
}
}希望这能帮到你至少在某种程度上
发布于 2015-02-26 14:36:43
WCF中的URL重写

创建新的WCF服务应用程序。
添加Global.asax文件。
在Application_Start方法中添加以下行:
RouteTable.Routes.Add(new ServiceRoute("api/Service1", new WebServiceHostFactory(), typeof(Service1)));在服务合同的操作合同中添加WebInvoke (接口IService1)。
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetData?value={value}")]构建和浏览项目。
检查这个:http://gunaatita.com/Blog/URL-rewriting-in-WCF/1052
https://stackoverflow.com/questions/27655684
复制相似问题