我需要向我的MVC控制器方法發送一個id,該方法是從json調用發送的。最後,我需要刷新屏幕。這工作正常:將多個參數傳遞給控制器
window.location.href = '/Reports/SpendingByCategoryByMonth/' + categoryId;
但是,我現在需要發送多個參數。所以,我的控制器方法需要命名的兩個參數,和我嘗試打電話給我的控制器是這樣的:
window.location.href = '/Reports/SpendingByCategoryByMonth/categoryId=' + categoryId + '&subCategoryId=' + subCategoryId;
但我得到的錯誤:
A potentially dangerous Request.Path value was detected from the client (&).
有沒有更好的方式來做到這一點 - 或者,我該如何解決?
您缺少'?'。 – undefined 2014-11-14 23:24:17
嘗試'window.location.href ='/ Reports/SpendingByCategoryByMonth?categoryId ='+ categoryId +'&subCategoryId ='+ subCategoryId;' – 2014-11-14 23:24:26