weixin_33736048 2017-02-12 09:48 采纳率: 0%
浏览 17

网站发布后的Ajax网址

I developed a site in asp.net. In my site, I have an ajax post which worked when I ran the site locally.

After I publish my site, it looks like the url for ajax post is changed.

I want to align the URL that when running the site locally will be the same as when the site is published

I published the site under folder name ResourceManager (it also the site name)

My ajax URL before publish the site

URL= "/testbed/ConnectTesbedToResource/";\\(<controller_name/method_name>)

after publish the site its NOT working and I need to change the URL to

URL = /ResourceManager/TestBed/ConnectTesbedToResource/;

How I can make sure that the URL will be the same for local run and for publish run?

I tried to change the URL to relative path with ~ (~/testbed/ConnectTesbedToResource/) and it also didn't work.

How can I make that after publish I will have same URL for jQuery post request?

  • 写回答

1条回答 默认 最新

  • 七度&光 2017-02-12 12:58
    关注

    Use URLs without a / at the start - / will make it relative to the site root, which, as you've seen, can change depending on the config of the server and where you install to. Without the / it will be relative to the current page, which is much easier to handle across different install locations

    评论

报告相同问题?