Search code examples
c#asp.net-mvcweb

Redirect public ip to domain name


I need that when someone enters my ASP.NET MVC / C# website typing its public ip in the browser, the user is redirected to the domain name.

Thanks

Regards

For example if I write 142.250.0.139, the browser redirects to google.com. I need that exactly to happen.


Solution

  • Just redirect on page load. You can test for if it came from ip address or domain if needed.