Consider a situation where you need to redirect your Application to the Error page when you receive a particular value in your query string. This can be done using URL Rewrite with an inbound rule either directly in IIS or add rules directly in your web.config.
Below configuration can be added in web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="BlockQS" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{QUERY_STRING}" pattern="P=abc" />
</conditions>
<action type="Redirect" url="https://website.com/ErrorMessage.aspx" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
If you check directly under IIS URLRewrite feature for your website, it would look like this:

Now, when you try to access https://website.com/?P=abc, it would redirect to the configured error page.
To install URL Rewrite, follow the link.