I have an ASP.NET MVC application (using .NET 4.5) deployed on a web server which has IIS 8.5 installed.
I have created a custom controller class where I do some stuff and it inherits from System.Web.Mvc.Controller:
public partial class MyCustomController : System.Web.Mvc.Controller
{
// Here my stuff
}
Then, all my controllers (except a few ones), inherit from my custom controller, for example:
public partial class OneController : MyCustomController
{
// Here some stuff
}
My goals:
- Now, I need to get the client IP address that is currently making the request to my ASP.NET MVC application. So I would like to implement a method within my custom controller, MyCustomController, that returns that client IP. Is this possible at this point? If so how?
- Additionally, how can I know if the incoming request comes from local IP address (localhost) 127.0.0.1 and then if so, discard this request, I mean, do nothing?