Controller
(1) This one is used for getting the parameter from WebUrl
// GET: /Store/Browse?genre=Disco
public string Browse(string genre)
{
string message =
HttpUtility.HtmlEncode(“Store.Browse, Genre = “ + genre);
return message;
}
return output: Store.Browse, Genre = Disco
using the HttpUtility.HtmlEncode utility method to sanitize the user input.
This prevents users from injecting JavaScript code or HTML markup into our view
with a link like /Store/Browse?Genre=<script>window.location=’http://
hacker.example.com’</script>.
The Other Method for get parameter from URL
// GET: /Store/Details/5
public string Details(int id)
{
string message = “Store.Details, ID = “ + id;
return message;
}
Output will be: Store.Details, ID=5