views:

39

answers:

2
<location path="/home/address?city="jcity" allowOverride="true">
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <httpRedirect enabled="true" httpResponseStatus="Permanent"
            exactDestination="true" destination="/home/jerseycity" />
    </system.webServer>
</location>

Error is location tag does not allow "?". What is the best way to do this redirect?

A: 

The location element's path attribute applies to files and folders, not URLs.

The best way to do this is probably to redirect within the code targeted by the /home/address URL itself, or if you're using custom routes, to set something up there.

Jeff Sternal
A: 

If you insist on doing redirects of that sort in web.config, which would require a separate entry for each city for which you want to redirect, you could do it in a "RESTful" manner, as such:

<location path="/home/address/jcity" allowOverride="true"> 
    <system.webServer> 
        <validation validateIntegratedModeConfiguration="false" /> 
        <httpRedirect enabled="true" httpResponseStatus="Permanent" 
            exactDestination="true" destination="/home/jerseycity" /> 
    </system.webServer> 
</location>

That'd require you to update all of your links and (I think) would require a folder structure that mimics your locations set up.

Alternatively, you could create a separate page whose job it is to redirect in the way you wish and redirect programmatically from that page. If you still wanted to declare URLs to destinations, you might add a custom configuration section to contain your mapping.

Randolpho