Explain Query String of Client Side Strategies.
Query String
- It is generally used for holding values
- It works temporarily
- It increases the performance of the app.
Example
We can pass a limited amount of data from one request to another by adding it to the query string of the new request. This is useful for capturing the state in a persistent manner and allows the sharing of links with the embedded state.
public IActionResult GetQueryString(string name, int age) {
User newUser = new User()
{
Name = name,
Age = age
};
return View(newUser);
}
Now let’s invoke this method by passing query string parameters:
/welcome/getquerystring?name=John&age=31
- We can retrieve both the name and age values from the query string and display it on the page.
- As URL query strings are public, we should never use query strings for sensitive data.
- In addition to unintended sharing, including data in query strings will make our application vulnerable to Cross-Site Request Forgery (CSRF) attacks, which can trick users into visiting malicious sites while authenticated. Attackers can then steal user data or take malicious actions on behalf of the user.
Comments
Post a Comment