2011-11-08 15 views
1

我嘗試將一段舊代碼移動到DNN模塊。該代碼通過JQuery調用Webservice(asmx)並顯示結果。 我將ASMX文件放在這裏:DesktopModules.MyModule.Service和App_Code \ MyModule文件夾中的後面代碼。DNN:從JQuery調用Webseervice

我可以通過http://localhost/DNN/DesktopModules/myModule/Service/myService.asmx直接調用服務 - 沒問題至今:-)

但是從調用該模塊的服務與此腳本

GetStats = function() { 

$.ajax(
{ 
    type: "POST", 
    url: "http://localhost/DNN/DesktopModules/myModule/Service/myService.asmx", 
    data: '{}', 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    failure: function (msg) { 
      Failure while call : " + msg); 
    }, 
    error: function (xhr, err) { 
      Error while call : " + err); 
    }, 
    success: function (response) {}}); 
    }; 

末,錯誤代碼400,似乎URL被重寫?!

我輸入 「http://localhost/DNN/DesktopModules/myModule/Service/myService.asmx」 和守則去這個網址 「/dnn/Default.aspx?tabid=82/myService.asmx」

友好的URL都關閉,有一個地方沒有重寫......

我不能找到一種方法 - 任何幫助,歡迎:-)

彼得

回答

0

你需要一個新在siteurl.config中輸入,這裏是給你的。

<RewriterRule> 
    <LookFor>.*myService.asmx(.*) 
    <SendTo>~/DesktopModules/myModule/Service/myService.asmx$1 
</RewriterRule> 

這將解決您的問題。

另一件好事是,如果你這樣做,localhost/myService.asmx它仍然會工作,因爲該規則