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

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

python - Pygame screen.blit not working -

c# - Web API response xml language -