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

RazorView.IUrlHelper makes it difficult to inject Url helper in views #816

Closed
pranavkm opened this issue Jul 18, 2014 · 1 comment
Closed

Comments

@pranavkm
Copy link
Contributor

We declare an IUrlHelper in the base type and @Inject does not support overriding this via new. The url helper is used by RazorView.Href method.

One possible work around is to consume IUrlHelper from RequestServices in the base type and inject it like IHtmlHelper and IViewComponentHelper.

public string Href(string path)
{
    if (_urlHelper != null)
    {
        _urlHelper = Context.RequestServices.Get<IUrlHelper>();
     }
     return _urlHelper.Content(path):
}

Thoughts? @yishaigalatzer

Follow up to #789

@pranavkm pranavkm self-assigned this Jul 18, 2014
@pranavkm pranavkm added this to the 6.0.0-beta1 milestone Jul 18, 2014
@pranavkm
Copy link
Contributor Author

cc @DamianEdwards @davidfowl

pranavkm added a commit that referenced this issue Aug 6, 2014
This allows for injection of the property in cshtml files wthout running
in to compilation errors

Fixes #816
pranavkm added a commit that referenced this issue Aug 11, 2014
This allows for injection of the property in cshtml files wthout running
in to compilation errors

Fixes #816
@yishaigalatzer yishaigalatzer modified the milestones: 6.0.0-beta1, 6.0.0-alpha3 Aug 16, 2014
@danroth27 danroth27 modified the milestones: 6.0.0-alpha3, 6.0.0-alpha4 Aug 16, 2014
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