Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Absolute URL Methods Added to UrlHelper, Canonical URL Support and RequireHttpsAttribute Fix #2810

Closed
wants to merge 6 commits into from

Conversation

RehanSaeed
Copy link

UrlHelper

Following on from #1966 where a Link method was added to UrlHelper which requires a route name and route values. Having similar methods for 'Action' (controller and action name) and 'Content' (images and static content) would be really useful too. Here are some places where I find having 'Absolute Content' useful:

  • Atom/RSS feeds require absolute URL's to image/audio/video (There is a way to specify a relative base URL but it's buggy in FireFox). See my ASP.NET MVC 6 Boilerplate example.
  • Creating a dynamic OpenSearch.xml file which contains absolute URL links to images. See my ASP.NET MVC 6 Boilerplate example.
  • Open Graph image/audio/video URL's are also required to be absolute.

I have these methods in my ASP.NET MVC 6 Boilerplate Framework NuGet package (Note that I add the word 'Absolute' at the beginning of the function. The current method is named 'Link' but it uses route names, so it could be named better at the very least).

Canonical URL's for Better Search Engine Optimization (SEO)

Support for canonical URL's with the RedirectToCanonicalUrlAttribute and NoTrailingSlashAttribute filters. Performing 301 permanent redirects to the canonical URL of a resource is the correct approach according to both Google and Bing. The RedirectToCanonicalUrlAttribute filter helps achieve this in conjunction with the RouteOptions (AppendTrailingSlash and LowercaseUrls). See my blog for full details.

@dnfclas
Copy link

dnfclas commented Jul 11, 2015

Hi @RehanSaeed, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@dnfclas
Copy link

dnfclas commented Jul 11, 2015

@RehanSaeed, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@dnfclas
Copy link

dnfclas commented Jul 11, 2015

@RehanSaeed, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@RehanSaeed RehanSaeed changed the title New absolute URL methods added to UrlHelper Absolute URL Methods Added to UrlHelper, Canonical URL Support and RequireHttpsAttribute Fix Jul 17, 2015
@davidfowl
Copy link
Member

@RehanSaeed The team will evaluate these changes but here's some initial feedback:

  • Split these unrelated changes into different PRs.
  • Check out the coding guidelines, the style doesn't match what we expect.
  • Add tests for each of the features implemented.

If you're just looking for initial feedback because this idea hasn't been cleared with the team then that should be reflected in either the title or description.

…tatus code when you only want to allow GET requests.
@RehanSaeed
Copy link
Author

Will split this pull request. Thank you!

@RehanSaeed RehanSaeed closed this Jul 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants