asp.net - On Form POST values are displayed in URL -


controller's action1 calls view contains following html code:

@using(html.beginform("action2","controller",new {id = viewbag.link},formmethod.post,new {@class =""})) {     @html.antiforgerytoken()     <input type="submit" value= "submit"/>  } 

when user submits form following method called:

[httppost] [validateantiforgerytoken] public async task<actionresult> action2(int id) {    //something    return view("display"); } 

when "display" view displayed url contains: //controller/action2?id=1

how avoid values being visible in url after formmethod post?

it happening because you're sending id route value. if want stay out of url, instead send via hidden input element

@using(html.beginform("action2")) {     @html.antiforgerytoken()     <input type="hidden" name="id" value="@viewbag.link" />     <input type="submit" value= "submit"/>  } 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -