---
title: "IIS Web.config 301 Redirect in ASP.NET including Parameter"  
description: "IIS Web.config 301 Redirect in ASP.NET including Parameter"  
author: "Anonymous User"  
published: 2014-11-10  
updated: 2014-11-11  
canonical: https://www.mindstick.com/forum/2552/iis-web-config-301-redirect-in-asp-dot-net-including-parameter  
category: "asp.net"  
tags: ["web config", "redirect", "url rewriting"]  
reading_time: 1 minute  

---

# IIS Web.config 301 Redirect in ASP.NET including Parameter

I'm looking into using [301 redirects](https://www.mindstick.com/blog/303405/site-migration-success-best-practices-for-implementing-301-redirects) having noticed a bunch of hits on my [domain](https://www.mindstick.com/articles/12298/how-to-select-seo-friendly-domain-names-for-your-new-website) on [Google Analytics](https://www.mindstick.com/articles/1504/google-analytics-setup-website-tracking-code) to .asp pages which not longer exist having moved everything over to a .NET setup.

Having spent a [bit](https://www.mindstick.com/forum/33411/how-we-tell-programmatically-if-i-m-running-in-64-bit-jvm-or-32-bit-jvm) of time Googling, I have been able to [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) to my web.config.

```
<location path="products.aspx">    <system.webServer>     <httpRedirect enabled="true" destination="https://www.mindstick.com/products.aspx" httpResponseStatus="Permanent" />    </system.webServer></location>
```

This is fine and moves everything from products.asp to pproducts.aspx but it does not preserve the [querystring](https://www.mindstick.com/interview/123/what-is-querystring-benefits-and-limitations-of-using-querystring), which is [essential](https://www.mindstick.com/articles/12260/why-it-is-essential-to-be-proactive-about-your-retirement-financial-planning) to make any sense, ie products.aspx?id=789

## Replies

### Reply by Anonymous User

You have to add $Q to the destination url to preserve the querystring. So in your case it should look like this:

```
<location path="products.asp">    <system.webServer>     <httpRedirect enabled="true" destination="https://www.mindstick.com/products.aspx$Q" httpResponseStatus="Permanent" />    </system.webServer></location> 
```


---

Original Source: https://www.mindstick.com/forum/2552/iis-web-config-301-redirect-in-asp-dot-net-including-parameter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
