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

Inconsistency with Url.Content("~") #2896

Closed
Daniel15 opened this issue Aug 3, 2015 · 1 comment
Closed

Inconsistency with Url.Content("~") #2896

Daniel15 opened this issue Aug 3, 2015 · 1 comment
Assignees
Milestone

Comments

@Daniel15
Copy link
Contributor

Daniel15 commented Aug 3, 2015

In previous versions of ASP.NET MVC, Url.Content("~") returns the application's root directory (ie. /foo). On ASP.NET MVC 6, this just returns a verbatim "", and you need to actually use Url.Content("~/"). It's a subtle difference, but it appears that older versions just check that the first character is "", whereas newer versions check that the string starts with "~/" (ie. it contains a tilde and a slash)

Old code:

bool isAppRelative = contentPath[0] == '~';

New code:

if (path.StartsWith("~/", StringComparison.Ordinal))
@Daniel15
Copy link
Contributor Author

Daniel15 commented Aug 8, 2015

Thanks! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants