0

I have this code in my view to hit one ActionResult

 ClearFilters = function () {
        $.get("/Mandate/Index/1");
        window.location.href = '<%=Request.Url.Scheme + "://" + Request.Url.Authority + Request.Url.AbsolutePath%>';
    }

My controller Method

Public ActionResult Index(int? id)
{
     //some code
}

with this Code I am able to hit Index Action Result but I am not getting int id value 1?

is that something I am doing wrong here?

Thanks

3
  • Have you defined the routing for this type of request? Commented Aug 6, 2011 at 1:07
  • Yes I have it. it was working before but not now. Commented Aug 6, 2011 at 1:09
  • This smells like a routing problem. Can you post your route definitions? Commented Aug 6, 2011 at 2:02

1 Answer 1

1

Try this. See if you get the id value, keeping all other code same.

$.get("/Mandate/Index", { id=1 }, success: function(){
   window.location.href = '<%=Request.Url.Scheme + "://" + Request.Url.Authority + Request.Url.AbsolutePath%>';   
});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Shanker Still I am not getting the value of id.. in my controller Action. thanks
Why are you setting the location.href right after $.get call. Can you do this in the success handler of $.get?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.