How to run a windows application as a web application - c#

I did a windows application project with C#. Now, I wanna to run it as web application.(I mean, i want to install the application on server and the user from other places can connect to the server with a web link and test it).Since all the user do not have the visua studio software, I forced to do that. May you help me to figure this problem out?
Thanks in advance

You can't do that. You can have people be able to Remote Desktop to the server and then run the application. If you wanted it to be accessible via URL, you have to build a webpage.

Short answer: you can't run a Windows application directly in a web environment. And really there is NO WAY you should want that, either.
If you need remote access to the computer running the instance of your application, that can be done with the right software. I can think of TeamViewer, Radmin and Remote Desktop on top of my head.
If support for multiple concurrent users is required then you have two obvious choices:
Deploy your application on every clients, or
Make a Web application.
Now for option 1, there are different ways to do that. Depending of the complexity of your app you may require a Windows Installer setup package. For this there is multiple tools on the net. My personal favorite is WiX. Free, powerful and easy once you get the hang of it. Most installers will also ensure that requirements for the app to run are met, and install the missing components if necessary.
If all you have is a simple EXE file then you could be tempted to just package (ZIP) it and share it any way you want, but be warned: if the correct .NET Framework isn't installed on the client machine, it won't work. IMHO given the tools at your disposition to ensure a proper installation experience for the end user, you have no reason to do that. You can, however, consider using ClickOnce for this scenario.
If that doesn't help you, then please add more details on what your requirements are, maybe you'll get better advice.
PS: About "not every users having the Visual Studio software"... having VS installed should never, EVER be a requirement for the regular user.

You can't just run a Windows application as a Web Application. You need to re-write it as a web application. The users do not need Visual Studio to run your application as you have mentioned in your question. If you give some details of what your application does then maybe you will get some better help.

If you wrote your application using WPF it is possible to deploy it as an XBAP.
There are restrictions associated with deploying an application this way.
The minimum you would need to do is create a Web Application to host said XBAP.

Related

Service to run installers with administrative privileges

I work at a company in which we need to restrict administrative access but allow the install of select programs with an easy way to update the list of programs. We want to develop a sort of appstore for everyone's PC where they can access the list of allowed apps and install what they need. We want to write this in C#.
To do this i have initially developed a windows service that starts as a localhost and runs at boot time giving it admin powers. I than use an application which talks to the windows service via a service hosted by the windows service. Long story short its told what app the user wants from the list and the list provides the file path for the application stored on a private repository.
This is a sort of very very early attempt at this and security is in mind and will be added once the concept functions.
Now onto the problem were having.... when we launch the installer using our service the installer window never launches in the desktop for the user to configure the options that could be in an installer. This of course poses a problem for a lot of our installers. After some quick research i understand why this happens due to what level the services run in the operating system and their inability to access the desktop.
My question is..... is there a way to solve this problem? a way to have a service launch at bootime and launch installers as an administrator on the users desktop? or is this too messy and creates too many issues? is there a way to do this with a console app or WPF?
Thanks in advance!
Indeed like what you found about windows services, I don't think this whole flow can work as a service. There seems to have some workarounds though, according to this thread: How can I run an EXE program from a Windows Service using C#?
If it's an app-store where users can choose what to install, maybe an application is all that's needed. Like you said:
I than use an application which talks to the windows service via a service hosted by the windows service. Long story short its told what app the user wants from the list and the list provides the file path for the application stored on a private repository.
Seems like an application can handle all the works here already.

Run desktop app via WEB app

I have desktop application that can be installed on the users computer with "setup" msi file like any other application.
I'm developing web application and I need somehow to integrate the desktop application with the web application. Web application is developed using PHP (desktop application is developed using C#), and when clicking on one button on the web application, the desktop application needs to be launched.
Is there a way of doing this? I was thinking about a few scenarios:
-Maybe if possible to install the app directly on the server and to launch it from there?
-Maybe to be required the user to have the app installed on his computer and to call the app from there?
If possible I would prefer to not use the second approach because it's better if the third party to not be involved - it will be more user friendly if the application is launched directly. But any help will be appreciated because at this point I'm not sure if that is possible to be done at all.
You can install app at server an run it with exec() or "`" operator - but to control gui of app you need to use some like autoit ant etc.
If you ultimately decide to require your users to have the client application installed and expect majority of the users to be on Windows, you could register your application to handle specific scheme and parse its command line when started. More on this here:
http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
You'd register a custom scheme and then intercept in in the application's command line arguments. The whole URL will be passed as an argument, e.g.:
myapp://parameter1,parameter2
The browser will mostly ask whether or not the user trusts the application to handle this scheme with an option to remember this setting.
If you don't have access to the source code of the client application, you can develop a middleware, some sort of a launcher that handles the URL and then runs the client application after maybe modifying some configuration files based on the URL or otherwise controlling the third-party application to do as you with.
As for solution #1, I don't think C# matters if your application can run on Mono, so you should be able to just run it from PHP. However, this probably won't work on web hosting and you will have to get a VPS for that.
There are very good (security) reasons why it is hard to launch client-side processes from web browsers.
Do you have access to the source code of the C# app? If so, you could consider modifying it to take advantage of Microsoft ClickOnce deployment.
Some references:
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/6ae39a7c.aspx
http://www.codemag.com/Article/0902031
Here's an old article on deploying WinForms applications via ClickOnce with Visual Studio 2005: http://msdn.microsoft.com/en-us/library/ms953320.aspx
It can possibly be done with IIS but it can be cumbersome setting it up to run as the current user, especially since it would probably also need to run elevated for an app that needs to attach to the current user's desktop.
Easiest is to install a Windows LAMP distro (like WAMP: http://www.wampserver.com/en/) and then run the httpd.exe directly from an elevated (Admin) command prompt; do not run apache as a service!
Once you do this performing and exec("command"); call in php will bring up a desktop app as if it was invoked from an admin command prompt. Obviously you need to set up the apache server to be accessible from outside the local system, etc.

Replacing Click-Once with another installer that supports non Windows Security

I currently have an in house C# app that is delivered via click-once. I'm moving to the cloud and would like to have the Click-Once delivered from there (will be accessed from multiple countries and I can't use IP ranges to block out intruders), but it appears that the only way to secure the download is using windows security which is not an option for my clients.
I'm looking for a nice way to deliver the initial software and then keep the clients updated.
I've heard about WIX but I can't seem to find any information around updates from the internet and it.
Does WIX support this? If so can someone point me at an example or reference?
If it doesn't support it is there another solution someone can recommend?
Here is my usage scenario:
- User logs into a website supplying credentials, (username/password or certificate) then has the ability to download and install the application.
The application must check on startup of the app for a new version and if there is automatically download, install then run it. (would be nice if the user must resupply credentials for the update but not a necessity)
Bonus points if it will work on any web server such as a simple Node.js implementation.
WiX Only handles the installation via the bootstrapper or MSI you have generated, so I would assume that it's most likely a windows installer setting of some kind when it is first created. The element ClickThrough is supposed to be able to handle this scenario, though I don't know much about that.
The way my work colleagues dealt with this is by using IIS and an ASP.NET web service, along with a DLL that has methods to check with the web service if there is an update, and then prompts the user about the update and asks if they wish to update (did I say update enough in that sentence?).
Hope this helps.

How to develop Smart Client Application

Hi.
I have several questions. I developed an application using Visual Studio 2010. The application is developed using Windows Form and the program was wrote using C#.
This application needs to be run on a server. There are several clients connected to the server that will access and use that application through the browser. I know this can be done using Smart Client technique. But I don't really understand how to do it. My questions are:
Is there any syntax/class/methods/function that I need to include in my application? How to use it?
What settings/configuration do I need to set up so that the client computer can access the application in the server through their browser?
I know this can be done using ClickOnce but I don't know how. Can anybody tell me or show me the steps that I need to do to implement this?
Is there any syntax/class/methods/function that I need to include in my application? How to use it?
There are a few - but this is a large area. I would point you at couple:
WCF
ASP.NET Web API.
I would advise to use the later as it appears to be where the modern development is heading (at least to me).
Put simply, you will write your own web server, host it either in your WinForms application or migrate your WinForms to be a web application and host it on IIS, for example. Your web server will expose some API, which will likely to be based on HTTP protocol. A client application will hit web URLs. This will be a request-response paradigm.
Because this is a large area, I cannot name you exact classes, but have a look at ASP.NET site for samples.
What settings/configuration do I need to set up so that the client computer can access the application in the server through their browser?
It depends on the technology. Usually it's pretty simple - get it from tutorials and samples. In most cases this will be *.config file XML code and some minor bootstrapping in .cs files.
I know this can be done using ClickOnce but I don't know how. Can anybody tell me or show me the steps that I need to do to implement this?
ClickOnce is a deployment tool. You probably don't need that at this point.

Can a web app access and modify the registry of Windows?

I've been writing desktop apps in C# for some time now but I'm increasingly getting frustrated with the fact that not everyone has .NET 2 or Higher installed. I don't have the option of upgrading their systems to meet my needs. My apps are mostly utilities that run alongside the main program the company I work for has. They access the file system and the registry. Being relatively new to programming in general, I was wondering if moving these tools to the web would solve some of my problems. But I have no idea if web apps can have access to these parts of Windows. I was thinking of writing these web apps in either Rails or ASP.NET. So my question is this. Can a web app access and modify the registry and file system of Windows?
Thanks.
Nope, "web apps" like asp.net or rails apps run on the server alone and just serve html to the client. So all the client-side code can do is what jscript running in the browser sandbox can do, ie no file access or registry access.
You can however install an activex on the client computer that gets full access, but the user has to agree to install it as it's a security risk.
Writing the apps as Web apps instead (and Rails is cool to use) is a good option - your users don't need to install anything, upgrades are easy to do, and dependancies are no longer a problem.
However, you now need to start re-architecting your apps so they do not need to write anything to the client, except a cookie (that's stored in the browser). If you can do this, then migrating to a webapp will be great.
If you cannot, my advice is to learn the same language that your company's app is written in. Once you do that, the company app will have taken care of the dependencies already and you will just need to offer your utilities alongside the app, perhaps even in the installer, or just to copy the files into a subdirectory. If you're thinking of learning Ruby, then learning the corporate language will be just as difficult (only you'll be able to reuse a lot of code used in the main app)
No, a traditional asp.net application cannot access the file system or registry on the windows box. Simply put because it doesn't actually run on the client machine. Instead it runs on the server where it does not have access to the local machine.
It is possible to have portions of the application which run on the client machine. Browser based applications for instance. However these would require that the 2.0 framework be installed on the customers machine which puts you right back at square #1.
No, this isn't possible. Web applications cannot modify the registry and/or file system on a user's machine because of the security implications. You would need to develop a Windows app to do these kind of changes. You could always make this tool available for download on your website though.
No, you can't do that with a web application. Besides others have already said, a web application run in a browser, not inside an operating system, so all you can do is what browsers allows you to do and not all you want, and browsers doesn't allows you to take control of the host machine.
I'm guessing the desktop app used in your company uses the registry to store workstation / user specific (state)data.
Moving to a web based app does not mean storing state data is no longer possible, just account for it by including a table in your database that can be used to save that same (state)data in. The registry is no longer needed.
Another pro is that by moving to a fully webbased application, you never have to worry about your endusers, because the code is running on the server, all the enduser gets is the output in html :-D.
The only thing to keep in mind is cross browser compatibility, don't create an app that works in IE only for instance, it has to look and work the same in all major browsers.
There are a few products out there, such as Xenocode and VMWare's ThinApp, that allow you to virtualize your app's dependencies to the point where your .NET app can run on a machine without the .NET Framework installed. Just another option from left field.

Categories