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

Add URL resolving TagHelper to replace Razor ~/ functionality. #2807

@NTaylorMullen

Description

@NTaylorMullen

This is in reaction to the conversation: aspnet/Razor#427 (comment)

Today Razor special cases ~/ at the beginning of attributes and treats them as "resolve an application relative URL"; however, it does this for every attribute which is overkill/incorrect. After investigating the attributes that have URL capability in Razor the list warrants something less hard coded into the core of Razor to resolve application relative URLs.

The list of HTML5 url based attributes I was able to find are:

  • href : <a>, <area>, <link>, <base>
  • src : <audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video>
  • action : <form>
  • cite : <blockquote>, <del>, <ins>, <q>
  • data : <object>
  • formaction : <button>, <input>
  • icon : <menuitem>
  • itemid : everything
  • manifest : <html>
  • poster : <video>
  • archive : <object>, <applet>

The TagHelper should exist in Microsoft.AspNet.Mvc.Razor and should be auto-added to Razor pages (much like how we auto add @inject directives). It should inspect TagHelperOutput.Attributes and TagHelperOutput.TagName for the various combinations listed above and resolve URLs if they begin with ~/. Lastly, it should have an [EditorBrowsable(EditorBrowsableState.Never)] attribute to prevent excess highlighting in the Razor editor (will work once aspnet/Razor#447 is completed).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions