简体   繁体   English

在服务器上发布后,asp.net mvc ajax调用未调用控制器

[英]asp.net mvc ajax call not calling controller after publishing on server

this is for the first time I am having a problem like this, 这是我第一次遇到这样的问题,

my code is running smoothly on my localhost, but i am getting the error of bad request after uploading the same code on my server, 我的代码在本地主机上运行顺利,但是在服务器上上传相同的代码后却收到错误请求的错误,

the following is the error I am getting, 以下是我得到的错误,

http://URL/Controller/Method 400 (Bad Request) http:// URL / Controller / Method 400(错误请求)

here is my code 这是我的代码

Controller:

    [Interceptors.AccountFilter]
    [HttpGet]
    public ActionResult method(string city, int bookmark)

Javascript:
        $.ajax({
            type: "GET",
            url: "/controller/method",
            data: {
                city: city,
                bookmark: bookmarks
            },
        })

what can be the possible issue that i am getting, 我得到的可能是什么问题,

PS: PS:

the code is running on localhost properly 代码在localhost上正确运行

将您的代码从url: "/controller/method"更改为url:'@Url.Action("method","controller")'

(我无法评论)请更改web.config上的“ customErrors”标记,以便您可以查看错误详细信息

<customErrors mode="Off"> 

Try taking off the first '/' so your url will become: "controller/method". 尝试删除第一个'/',这样您的网址将变为:“ controller / method”。

I would also put a piece of code in the first line of the method to check that the address is correct and is triggering. 我还将在方法的第一行中放入一段代码,以检查地址是否正确并正在触发。

You can also try temporarily commenting out the two lines below. 您也可以尝试暂时将以下两行注释掉。 They aren't needed for testing and looking at the first attribute would probably stop your request. 测试不需要它们,查看第一个属性可能会停止您的请求。

[Interceptors.AccountFilter]
[HttpGet]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM