MVC Redirect to View from jQuery with parameters

前端 未结 4 1934
谎友^
谎友^ 2021-02-05 14:48

I have seen some posts relating to this but can\'t seem to get it to work. With the redirect I get a \'resource cannot be found error\'.

I am trying to redirect to a De

4条回答
  •  执念已碎
    2021-02-05 15:04

    If your click handler is successfully called then this should work:

    $('#results').on('click', '.item', function () {
                var NestId = $(this).data('id');
                var url = "/Artists/Details?NestId=" + NestId; 
                window.location.href = url; 
            })
    

    EDIT: In this particular case given that the action method parameter is a string which is nullable, then if NestId == null, won't cause any exception at all, given that the ModelBinder won't complain about it.

提交回复
热议问题