I have an application that's locked down using forms authentication. There are few nightly tasks I want to script that make get requests to, say, http://myapp.domain.com/NightlyTask ... I don't need any response, I just need it to accept a get request from a certain IP address. I realize you coul开发者_运维百科d spoof an IP address, etc. but I'm trying to make this dead simple.
Is there anyway I can setup the Web.config to unconditionally give access to a certain IP? Any other idea to approach this?
Again, long-term solution would be a service running Quartz or some other cron-like job handler. I'm not quite there yet, hoping for an interim solution. Thanks!
Not recommended for various security reasons but if you must, you can create your own authorization filter
public class AuthFilter : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.HttpContext.Request.UserHostAddress == "127.0.0.1")
return;
base.OnAuthorization(filterContext);
}
}
you would substitute 127.0.0.1 for your ip and this would work.
精彩评论