Hide querystring in url using MVC 5

Bart Schelkens picture Bart Schelkens · Feb 24, 2015 · Viewed 7.5k times · Source

Hi i have this application that needs a user to login. Once the user is logged in, he is redirected to a page displaying documents for that user.

To display that information, I call the correct action on the controller and i pass my user-object. This object contains username and password. When i look at my url it looks like :

http://localhost:53703/Documents?UserName=bart&UserId=10&Password=AllPhi%242015

Is there a way that I can hide those querystring-values (UserName=bart&UserId=10&Password=AllPhi%242015)

Answer

Daniel picture Daniel · Feb 24, 2015

I can not object strongly enough to sidestepping the built in auth-mechanisms, but to answer the question: You cannot hide the query-string. If you want to hide data when you are sending from a client you need to do a post request instead of a get, but the post-data is still visible in the request (in plain text)

But in this case it seems you want to pass data between actions, and then you want to use tempdata. Look here for reference: http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications