1

Possible Duplicate:
Add a trailing slash at the end of each url?

I need to append a forward slash on the end of the ActionLink. How would I do that? This is for SEO purposes.

@Html.ActionLink("About Us","Index","About") 

From this: http://www.somesite.com/About

To this: http://www.somesite.com/About/

Community
  • 1
  • 1
Greg Finzer
  • 6,714
  • 21
  • 80
  • 125
  • 1
    here's a post that likely will help: http://stackoverflow.com/questions/1385265/add-a-trailing-slash-at-the-end-of-each-url – MrBoJangles Jan 17 '12 at 22:12
  • 1
    This is clearly not an exact duplicate, at all. The OP asked for adding a trailing slash to a single ActionLink, not EVERY URL on the site, like the other question. – Ehryk Oct 18 '12 at 08:48
  • OP: In the `Index` case, use `@Html.ActionLink("Text", "/", "Controller")` otherwise use `@Html.ActionLink("Text", "Action/", "Controller")` – Ehryk Oct 18 '12 at 08:49

1 Answers1

0

You can also use the URL rewrite module to enforce your SEO requirements throughout the site, without the need to write specific route functionality. This is managed from your web.config...

<rewrite>
    <rules>
        <rule name="Remove trailing slash" enabled="true" stopProcessing="true">
            <match url="(.*[^/])/$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_METHOD}" pattern="POST" negate="true" ignoreCase="true" />
                </conditions>
                <action type="Redirect" redirectType="Permanent" url="{R:1}" />
        </rule>
    </rules>
</rewrite>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Neil Kinnish
  • 401
  • 3
  • 3