weixin_33682719 2014-04-04 17:17
浏览 22

网址重写和Ajax调用

i have a problem with calling web method ( [WebMethod] ) from ajax when i'm using url rewrite to remove the page extention (.aspx).

my ajax works good with rewrite off as follow:

"mypage.aspx/UpdateOffer"

but when i use rewrite i get "parsererror" message from ajax

so i tried this :

"mypage/UpdateOffer"

but then i get error "undefind"

i tried this also ( as suggested by others): PageMethods.set_path(PageMethods.get_path() + '.aspx');

then : "mypage.aspx/UpdateOffer" failed.

also tried : "mypage/UpdateOffer"

failed.

so, how can it be done without errors ?

ty

Edit: my ajax :

PageMethods.set_path(PageMethods.get_path() + '.aspx');
$.ajax({
    url: "myPage.aspx/UpdateOffer",
    type: "POST",
    contentType: "application/json;charset=utf-8",
    dataType: "json",

. . . .

Rewrite config:

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="extensionless" stopProcessing="true">
          <match url="(.*)\.aspx" />
          <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="removeextension" enabled="true">
          <match url=".*" negate="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:0}.aspx" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题