asp.net mvc - Passing date parameters to @url.action via ajax -


in asp.net mvc 4 app, i'm using following jax code taken stackoverflow post pass date parameters controller getting following http 404 error: "the resource looking has been removed, had name changed, or temporarily unavailable. requested url /mywebapp/mycontroller/myaction/01/01/2014/12/31/2014"

here input controls txtfrom , txtto have values 01/01/2014 , 12/31/2014 respectively. issue mvc interpreting each date 3 different parameters. how can fix it. tried replacing $('#txtfrom').val() $('#txtfrom').val().replace("///g", "_") not work.

window.location.href = '@url.action("myaction")/' + $('#txtfrom').val() + '/' + $('#txtto').val(); 

action method:

public actionresult myaction(string startdate, string enddate) {  //simple code here use input parameters } 

you either format date string razor

@httputility.urlencode(date) 

with javascript

encodeuricomponent(date) 

or pass date ticks (milliseconds since epoch) instead of human-readable format.

edit:

after experimenting , bit of research seems slash , %2f encoding causes kinds of problems. stick millisecond representation date , not worry passing slash.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -