perhaps? 2017-06-26 17:06 采纳率: 100%
浏览 18

MVC无效的URL参数

I have small experience with ASP and Javascript.

I'm working on a ASP.NET MVC5 project and I'm having a problem with Ajax Call to a method The Jax call go like this :

        $.ajax({
            data: { 'param1': param1Id, 'Param2': param2Id},
            datatype: "json",
            type: "GET",
            url: "../PartSelector/SearchPart",
            cache: false,
            success: function(data) {
                $('#SearchPart').html(data);
            }

        });

But I keep getting the error HTTP404: INTROUVABLE - Le serveur n’a rien trouvé correspondant à l’URI (Uniform Resource Identifier) demandé. (XHR)GET - http://localhost:10473/Locator/PartSelector/SearchPart?param1=CR00061752&param2=6101&_=1498495699141

My controler look good

public ActionResult SearchPart(string param1, string param2)
{

}

But when I take a look at the URL a strange parameter is added: "&_=1498495699141" I don't know where this parameter came from.

Can someone help? Thanks

Hugo

</div>
  • 写回答

2条回答 默认 最新

  • weixin_33716941 2017-06-26 17:58
    关注

    Like what Sparrow said, you need to check if you have [HttpPost] above your controller action. If it's there, then the ajax is not being allowed by the controller since it's of type 'GET'.

    Other than that it looks fine to me. Open up the debugger in your browser -> go to Network tab -> click on your action event that causes the ajax call -> look back at the debugger and click on the most recent event (the ajax call) -> go to Network tab -> read off what your 'params' and your 'response' says, then I think I'll be able to help you.

    评论

报告相同问题?