iis 6 - Recycle App Pool on IIS6 using C# -
i'm attempting recycle app pool on iis6 programmatically through web application. have searched on net , found bunch of solutions (most involving impersonation) none of them seem work. common error e_accessdenied despite entering valid username , password. can point me in right direction?
the solution use sort of thing (where you're trying run process asp.net needs administrative privileges) following:
- write whatever need done self hosted wcf service. preferably http rest service, it's easy call (even using browser testing)
- make sure service run using administrator account. can use task scheduler make sure service running @ times run using administrator account.
- execute methods on service asp.net application using wcf client
and works time no matter "process" i'm trying run within asp.net application.
now far details (code) concerned let me know if need help. code below code you'd have in console application in order make self hosted wcf service.
in case it's http service listening on port 7654.
static void main(string[] args) { var webservicehhost = new webservicehost(typeof(appcmdservice), new uri("http://localhost:7654")); serviceendpoint ep = webservicehhost.addserviceendpoint(typeof(appcmdservice), new webhttpbinding(), ""); var servicedebugbehavior = webservicehhost.description.behaviors.find<servicedebugbehavior>(); servicedebugbehavior.httphelppageenabled = false; webservicehhost.open(); console.writeline("service running"); console.writeline("press enter quit "); console.readline(); webservicehhost.close(); }
appcmdservice wcf service class looks (in case). in case don't need response service. in case i'm getting json response. actual implementation of you're trying different obviously. i'm assuming have piece worked out. call method of class here.
[servicecontract] public class appcmdservice { [webget(uritemplate = "/getcurrentexcutingrequests/?", responseformat= webmessageformat.json)] [operationcontract] public ienumerable<executingrequestjson> getcurrentexcutingrequests() { return currentexecutingrequestjsonprovider.getcurrentexecutingrequests("localhost"); } }
on asp.net side, don't need wcf client. need way make http call service. can use httpwebrequest make call out service, in turn execute process.
hope of makes sense?
Comments
Post a Comment