I am working on a MVC3 application. I want to call a function when the date is expired. I would like to use the windows service for this. Can anyone tell me steps to implement the window service in a MVC3 application? I am also open to any other options to call a function at a certain date.
Not possible. the application pool dies after a while. Create one MVC3 application and one Windows service.
you can use console application and set it with window Service or create Scheduler (crone) by task manager might be it will helpyou
and its going to more easy to us if you more describe what exact-ally you are looking for
you can implement the WCF services as a Windows service and create a call back in your Mvc3 application layer
take a look at this link for Creating Duplex Services
http://msdn.microsoft.com/en-us/library/ms731064.aspx
Related
I want to call my custom windows service running on particular client machine from my Web application on button click. How can I do this?
I got the solution and it works. Please find below steps.
Created Self-Hosted WCF service that call window services/processes
Call this WCF service from your web application
Please find below link for more details:
https://techinqueincsharp.blogspot.com/2019/05/open-clients-machine-local-file-from.html
I have a .NET MVC web app and a Windows Service running on the same machine. Both projects use the same database through a different Data Access Layer project.
I need the Windows Service to perform some actions on the database, and i know there are different options, just want to know which is the correct:
1.- Calling an Action on the .NET MVC web app that also performs the same actions needed by the Windows Service. To do so i would call the Action with a standard "HttpWebRequest" call.
2.- Creating a Web API controller on the .NET MVC web app and calling it from the Windows Service using the WebApi.Client library.
3.- Creating a new WCF project to create a new service and calling it from the Windows Service.
I'm not familiar with any of the options above, so please feel free to post the correct way to do it.
How about creating a class library with the code you want to run and use it in both the web app and the service? I call that option 4.
I have created an asp.net console application using visual studio 2012, the console application is a sync job between our ERP system and our custom Database. now i need this sync job to run on timely basis , so i created a new task under our windows task scheduler , which calls the console application each hour, which works well.
but i need to have the ability to run the console application manually by end users,, mainly users can login to our web application (asp.net mvc) and from there they can click on "Sync" button , where this "Sync" button will mainly calls the console application... so is this possible ? i mean can i have my web application calls the console application , the same way the Task Schuler calls the console application ?
second question, if I manage to call the console application from my asp.net mvc web application,, will this force the console application to run under IIS ? or the web application can call the console application outside the IIS scope ? similar to calling the console application from Task scheduler ?
Question 1: Yes you can.
public ActionResult Index()
{
Process.Start(#"c:\Windows\System32\cmd.exe");
return View();
}
Question2: The process will run under the IIS account, which may not have the privileges your process needs. You can impersonate another user before calling Process.Start(). See this example:
Change user for running windows forms program
You can create a web service(use asp.net web api) and put your synchronization code inside that. The Web API can be hosted in IIS ( or you can do a non IIS hosting as well) and you can access this web api endpoint from your asp.net mvc application when user clicks on the sync button in the UI. You may use HttpClient class to make the Http call to the web api.
Now from your console application, which is being invoked from the task scheduler, you can do the same. ie: you can use HttpClient class to make an http call to the web api endpoint which executes your code to sync your data.
While this answers your original question, It is not a good idea to run such a background task on an asp.net thread. The App domain can go down at any time for a lot of reasons and it will take down your long running task as well. But fortunately there are some elegant and simple to use solutions available.
HangFire
FluentScheduler
Quartz
These libraries have been designed around some of the pitfalls of manually running some code in the background in ASP.NET. Take a look at this blog post where scott explains how to use these libraries.
create a web api which communicates to a windows service (possibly using grpc).
user clicks button --> request hits web api endpoint --> grpc call to windows service (grpc server) --> windows service runs the application
You can execute any command from your web application
you can look here
Run an exe from C# code
I am developing an android application to accommodate some desktop software that I created. I would like for the user of the mobile app to have to verify their identity through authentication. Basically the web service will have to act as a central hub to both authenticate and hold information that the android app will need. The way I think it should work is to
-Set up a central web service
-Allow user to create account from desktop client using email/password
-The desktop client will send the information to the webservice that the android app will need.
-when android app is authenticated it will then retrieve the data it needs that was posted from the client.
So basically the service will need to be able to send and receive data.
I will only be using .net (either C# or vb.net ) for the service, so this leads me to a couple of questions:
Should I be using WCF for this? If so should I create a WCF Service library or WCF Service application?
Should I be using the Sign Sign on service approach?
The web service doesn't need to be fancy it just needs to get the job done. Is their any boilerplate project templates or projects out their I could use to help build a foundation?
I recently discovered SudzC.com which generates classes and methods for Objective-C from the wsdl data of a .net web service, and I'm fairly sure it also does Android.
I have a huge catalog of fairly 'old' web services which pre-date WCF and they are currently working perfectly.
I should point out though that the SudzC service only shows you what it can do for you for free - to get the code you have to pay ~£20 for a one year pass.
We had something similar where I worked. We had to put together an Android app for the company. If you are on .net 4.0 or newer, you can take advantage of theWebApi. It can return json or xml. So, that means any platform can utilize it (desktiop, android, etc...). I found it extremely easy to use, with very little overhead.
Hello i have to develop an application in which im able to send some data(notification) from my webform to windows form and similarly from winform to webform.
Someone told me that i have to use web service for this purpose. so if someone please tell me how can i do that?
Im using C# for this purpose.
The general pattern from Web forms -> Win forms:
Add a WCF service to your Win forms application.
Implement the interface.
Use a ServiceHost and start the service somewhere in your initialization code.
Start your Win Forms project.
In your web forms project, Select References -> Add Service Reference.
Enter the URL in the Forms application's config file. (this is added when you create the service) the service should be discovered and proxy code generated automatically.
rebuild the Web forms project, you should have access to the Win forms service methods.
Services in the other direction are similar, but you don't need a ServiceHost implementation (IIS will host the service automatically)
You'll probably want further configuration as well. Possibly different bindings, and security.