How hide some values from UrlRouting querystring?RSS

1 reply

Last post Nov 28, 2016 01:47 AM by Yuk Ding

  • How hide some values from UrlRouting querystring?

    Nov 25, 2016 09:45 AM|aizapro|LINK

    I have urls like to:




    I want to show only the family name in link

  • Re: How hide some values from UrlRouting querystring?

    Nov 28, 2016 01:47 AM|Yuk Ding|LINK

    Hi aizapro,

    If you means that you want to hide part of the URL for the specific URL http://localhost:6031/Post/2/sarah/nelson, then you could use my following script:

                    <rule name="URL redirect" stopProcessing="true">
                        <match url="(.*)" />
                            <add input="{REQUEST_URI}" pattern="Post/2/sarah/nelson" />
                        <action type="Redirect" url="Post/nelson" appendQueryString="false" redirectType="Temporary" />
                    <rule name="rewrite back" stopProcessing="true">
                        <match url="(.*)" />
                            <add input="{REQUEST_URI}" pattern="Post/nelson" />
                        <action type="Rewrite" url="Post/2/sarah/nelson" appendQueryString="false" />

    If you means you want to hide all the extension name with rewrite rule, I think it is unavailable. Because if you need to hide the URL, you need a redirect rule to the target URL and a rewrite rule to rewrite back. However, when the URL has been redirected, then the redirected URL doesn't know which URL should it rewrite back. So the rewrite rule could hide the name for only one URL. If you need to manage multiple URL, please create multiple rule for different names.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.