asp.net mvc - Invoking MVC Controller inside Azure worker -
i not sure if approaching correctly. have mvc controller action need call periodically. trying create scheduler quartz.net , need run scheduler in worker. how can access mvc controller action inside worker role?
you make http request action's route url worker role.
using (var httpclinet = new httpclient()) { var result = httpclient.downloadstring("http://www.site.com/path/to/action"); }
update
...how can current url inside worker role? because url change depending on being deployed...
one way store variable url segments in worker role's configurationsettings
.
<role name="my.workerrole"> ... <configurationsettings> <setting name="urlscheme" value="https" /> <setting name="urlhost" value="www.site.com" /> <setting name="urlpath" value="path/to/action?param1=value1" /> </configurationsettings> ... </role> using (var httpclinet = new httpclient()) { var url = string.format("{0}://{1}/{2}", roleenvironment.getconfigurationsettingvalue("urlscheme"), roleenvironment.getconfigurationsettingvalue("urlhost"), roleenvironment.getconfigurationsettingvalue("urlpath")); var result = httpclient.downloadstring(url); }
you can change values in serviceconfiguration.cloud.cscfg
file before deploying.
Comments
Post a Comment