how to redirect to a url in mvc view
I am implementing live search and when the user selects any of the options then accordingly the page gets redirected depending on the option selected.
I have jquery for implementing live search .
In the select option :-->> I want to redirect my page to Index Function in the HomeControllers file using javascript. The Index function has a few parametres inside it ...
I am not able to redirect ... the url to which i want to send .. gets appended to the current url.
I am doing window.location = "Home开发者_C百科/Index/"+ ui.item.value;
kindly suggest what to do ??? waiting for a reply soon.
You're using a relative URI. You need to use an absolute URI. So instead of
window.location = "Home/Index/"+ ui.item.value;
Do
window.location = "/Home/Index/"+ ui.item.value;
Note the extra /
You could do it in this way
window.location = '<%=Url.Action("Index", "Home")%>?/' + ui.item.value;
精彩评论