0

I'm following solution which is described here

my controller in mvc3 is decorated with custom FilterIP attribute like this

 //Admin/Device/Edit/1
    [FilterIP(
            ConfigurationKeyAllowedSingleIPs = "AllowedAdminSingleIPs",
            ConfigurationKeyAllowedMaskedIPs = "AllowedAdminMaskedIPs",
            ConfigurationKeyDeniedSingleIPs = "DeniedAdminSingleIPs",
            ConfigurationKeyDeniedMaskedIPs = "DeniedAdminMaskedIPs"
    )]
    public ActionResult Edit(int Id).... ommiting

and in Web.config I'm having these values inside appSettings

 <appSettings>
  <add key="AllowedAdminSingleIPs" value="89.111.212.141"/>
  <add key="AllowedAdminMaskedIPs" value="10.2.0.0;255.255.0.0"/>
  <add key="DeniedAdminSingleIPs" value=""/>
  <add key="DeniedAdminMaskedIPs" value=""/>
 </appSettings>

Now, I'm using http://www.whatismyip.com/ to discover my current ip (cause I'm having dynamic ip from isp). As far as I know this should work after I use my ip inside . 89.111.212.141 is my isp dynamic ip. But it doesnt work.

What can be a problem ? I'm constantly redirected to login when reacing decorated controller action. Just to mention, when using localhost as a AllowedAdminSingleIPs it is working.

Community
  • 1
  • 1
BobRock
  • 3,477
  • 3
  • 31
  • 48

1 Answers1

3

If you have hosted your application locally (VS built-in web server) and accessing it locally chances are your IP is 127.0.0.1 as returned by httpContext.Request.UserHostAddress. Try debugging the code by placing breakpoints in order to see what's going on.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I am hosting locally inside vs and trying to access my controller locally inside debug mode. When I change key value from localhost to 127.0.0.1 access do not work again. Basically only when using localhost as a value it's working. Is this means that It should be fine when my app be hosted online ? – BobRock Apr 18 '12 at 12:07
  • @hi, darin, allow the certain IP addresses access mvc pages that would otherwise be inaccessible to the public, how that can be done ? [here](http://stackoverflow.com/a/29368702/2218697) is my problem for facebook share, will [this](http://www.sasanyeganegi.com/2013/12/how-to-restrict-access-by-ip-in-aspnet.html) work or should i ask a new question ? – Shaiju T Mar 31 '15 at 12:53