Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How do I get route values from inside a View Component controller?

$
0
0

I have a View Component in _Layout.cshtml. My application has a route of /home/{id}. How can I get the id value in my URL route from the View Component controller?

public class LayoutViewComponent : ViewComponent
{
    public async Task<IViewComponentResult> InvokeAsync()
    {
        //how do I get the value of {id} here?

        return View();
    }
}

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>