首页 新闻 赞助 找找看

wcf 如何模拟个访问路径?

0
悬赏园豆:30 [已解决问题] 解决于 2013-05-06 14:54

我使用wcf做的网络服务  用ajax提交的方式访问 ,但是现在直接提交到了svc文件那里 现在我想让他提交的一个虚拟路径里 wcf好像可以这样 请问该怎么实现这个。

Arthur.Wang的主页 Arthur.Wang | 初学一级 | 园豆:25
提问于:2013-04-19 09:40
< >
分享
最佳答案
0

哦,你在 服务的Global.asax.cs 加上

Global.asax.cs
 1 void Application_Start(object sender, EventArgs e)
 2         {
 3             RegisterRoutes();
 4         }
 5 
 6         private void RegisterRoutes()
 7         {
 8             // Edit the base address of Service1 by replacing the "Service1" string below
 9             RouteTable.Routes.Add(new ServiceRoute("data", new WebServiceHostFactory(), typeof(Service)));
10         }

 

 

这样 你就可以通过 Jquery

View Code
function getProducts() {
            $.ajax({
                url: "http://localhost:15060/data/GetCollection",

 

访问了

收获园豆:30
weblogical | 初学一级 |园豆:6 | 2013-04-19 09:53

有没有通过修改wcf的配置文件来先这个效果的??就是web.config里

Arthur.Wang | 园豆:25 (初学一级) | 2013-04-19 14:14

@yahue: 没遇到过,如果有高手实现了,教我,谢谢!

weblogical | 园豆:6 (初学一级) | 2013-04-19 14:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册