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.
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.