Skip to content

Instantly share code, notes, and snippets.

@Abhinay-g
Created February 8, 2018 06:33
Show Gist options
  • Save Abhinay-g/ef4705f0e235a6258672335f5a3e1c17 to your computer and use it in GitHub Desktop.
Save Abhinay-g/ef4705f0e235a6258672335f5a3e1c17 to your computer and use it in GitHub Desktop.
Query String :
while redirecting from controller we can pass Query string as follows:
return Redirect("/Customer/CustomerHome?username=" + username);
Now to use Query String on respective page use below code
<h4>Welcome @Request.QueryString["username"]</h4>
** Now if you want that this Username is displayed over all pages using "Session" is a better Idea
Use Session variable in controller as follows
Session["username"] = username;
To use this session variable on all page
<div class="col-md-3">Welcome @Session["username"]</div>
Better way include this session variable in _layout file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment