How to Get the Base URL in ASP.NET MVC Core View , ASP.NET MVC Core get website link in View

21. April 2020

Get the Absolute URI from ASP.NET MVC Content or Action.

How to Get the Base URL in ASP.NET MVC Core View ?

ASP.NET MVC Core get website link in View .

 

Answer to above questions when i was trying to find what i actually wanted is below .

@Url.Action(<action>,<controller>,null,Context.Request.Scheme)

You can replace the <action> and <controller> with your values in double quotes if you want to get the exact link of a action method .

It will generate a link like - http://www.clanstech.com/Home/Services

Or you can also ignore <action>, <controller> altogether to get just the base url , website link , domain link on which you are hosting your website application .

Like this @Url.Action(null,null,null,Context.Request.Scheme)

It will generate a link like - http://www.clanstech.com/

ASP.NET MVC, ASP.NET MVC Core, C# , , , , ,

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading