I’m making an ASP.NET application that needs to run an action every 30 minutes and send out emails if certain conditions are met. I’ve got Windows tasks scheduled on the system hosting the site to run a program that will post to that action with a [LocalOnly] attribute. This is great when I’m testing during development because I can just send requests to http://localhost:%5BPort%5D/%5BController%5D/%5BAction%5D. However, once I’ve got the site deployed, using the public domain name for the request causes it to be routed through the internet, which means the IP is no longer local, which causes the action to fail.
Is there a way to submit this request locally? I’m hoping there’s some way to figure out a localhost address that I can just use instead of the site’s public domain name or IP.
…Or is there a better way to send emails every 30 minutes?
You can do this by creating a unique port binding on the deployment server in IIS.
Store this port number in some kind of config for the service you are running (or pass it in as a command line parameter to your scheduled task).
Update your call to http://127.0.0.1:%5BPortThatWasPassedIn%5D/%5BController%5D/%5BAction%5D.
Hope this helps, cheers.