SEO: Duplicated URLs with and without dash “/” and ASP.NET MVC
صفحه اصلي

SEO: Duplicated URLs with and without dash “/” and ASP.NET MVC

after reading this article "Slash or not to slash" (link: on Google Webmaster Central Blog (the oficial one) I decided to test my ASP.NET MVC app.

For example: and (with "/" in the end), return the code 200, which means: Google understands it as two different links and likely to be a "duplicated content". They suggest to choose the way you want... with or without dash and create a 301 permanent redirect to the preferred way.

So if I choose without dash, when I try to access it will return a 301 to the link without dash:

The question is, how can I do that with ASP.NET MVC?

Thanks, Gui

using MultiSelectList in ASP.NET MVC


ASP.NET MVC Form Submit with Link instead of Button
If your using IIS 7 you could use the URL Rewrite Extension ScottGu has a blog post around it here.. Using jquery to generate a Slug from Title (on lost focus) Alternatively if you want to did it in code you could inherit from PerRequestTask. Is it possible to load content dynamically through ajax (instead of upfront) in simile timelineHere any sample code the removes the www from an address - this is from Shrinkr:. Error when Saving into SQL Server
public class RemoveWww : PerRequestTask {     protected override TaskContinuation ExecuteCore(PerRequestExecutionContext executionContext)     {         const string Prefix = "http://www.";          Check.Argument.IsNotNull(executionContext, "executionContext");          HttpContextBase httpContext = executionContext.HttpContext;          string url = httpContext.Request.Url.ToString();          bool startsWith3W = url.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase);         bool shouldContinue = true;          if (startsWith3W)         {             string newUrl = "http://" + url.Substring(Prefix.Length);              HttpResponseBase response = httpContext.Response;              response.StatusCode = (int) HttpStatusCode.MovedPermanently;             response.Status = "301 Moved Permanently";             response.RedirectLocation = newUrl;             response.SuppressContent = true;             response.End();             shouldContinue = false;         }          return shouldContinue ? TaskContinuation.Continue : TaskContinuation.Break;     } } 
You would just need to check for the url ending with a / in your code. ASP.NET MVC iframe load. ASP.NET ActionFilters and inheritance ** Note this does use a 3rd party dll - System.Web.MVC.Extensibility namespace. Constructing controller action URL within JQuery AJAX call**.


It dosnt matter really for Google, although what does matter is if both urls' and show the same page, you also need to watch with windows servers this links to your site like from external pages where the user has typed will aloso be seen as a diffrent page as the web is case sensitive. . There is away round this with the use of canonical url meta tag, it tell s google what the page name is really, so will avoid duplicate pages which ant really diuplicate.


you need to check the URI in the INIT event and check the URI to see if it coming in with the slash, if it is, simply did a redirect and add the 301 header to the output response..

92 out of 100 based on 57 user ratings 452 reviews