How can I get the current domain url in Asp.Net MVC Core 6?

mehmood tekfirst 771 Reputation points
2022-07-19T14:44:07.537+00:00

Hi,

How can I get the current domain url in Asp.Net MVC Core 6?

I need to get it in my views and controllers

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,618 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 28,536 Reputation points
    2022-07-19T15:05:02.81+00:00

    How can I get the current domain url in Asp.Net MVC Core 6?

    Why? This need indicates an issue with the general design.

    [HttpGet]  
    public IActionResult Index()  
    {  
        string host = HttpContext.Request.Host.Value;  
        return Ok(host);  
    }  
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.