Can I create a Windows Form app using ASP.NET?
Asked Answered
U

2

5

I am very new to ASP.NET. I just found something interesting when I try to create an ASP.NET application.

I created a button, and wrote the following code in a click event handler:

protected void Button1_Click(object sender, EventArgs e)
{
    Form FormMain = new Form();
    FormMain.Show();
}

I then tried to add a reference to System.Windows.Forms. I ran it, and it worked. When I click on the browser button, a WinForms form appears.

Can I use this technique to build a desktop application such that all the code is in the web?

Ulyssesumayyad answered 15/11, 2013 at 1:6 Comment(3)
Technically, "all code" is in classes, .NET assemblies, not in WebForms of WinWorms.Beberg
Interesting. Have you tried accessing this function on another computer with in the network? The only thing I can think of that might be a problem is : what if your user doesn't have the same version of .net framework installed in your computer?Find
I have not tried it, I'm wondering if someone has tried thisUlyssesumayyad
C
7

No, Web applications run in the server.

Desktop Applications run in the client.

This only works because you're running it locally, but it will not work when deploying the ASP.Net Web Application to a Web Server.

If you need to create Web Applications, then use the standard ASP.Net techniques which deliver HTML [+ JavaScript + CSS] content to the browser. You may choose between "traditional" ASP.Net WebForms, or ASP.Net MVC.

If you need to create Windows Desktop Applications, use WPF.

If you need to create Windows 8 "Metro Style" Applications, use WinRT XAML.

winforms is completely useless at this point.

Cyndi answered 15/11, 2013 at 1:15 Comment(3)
He probably doesnt mean to publish WinForms somewhere but locally. It will work but I just can't realize reasons he needs that.Beberg
Actually I already make a windows application from C# desktop app, now I want to turn it into a web-based app, but I really new in asp.net, and I seek the best solution for me to do this.Ulyssesumayyad
no, you can't turn it into each other :) Not possible. They work different ways.Beberg
B
1

You can do that but this won't give your users any advantages. If you need shared logic than create it as a stand-alone project so it compiles to an independent assembly, after that you can publish it anywhere.

Beberg answered 15/11, 2013 at 1:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.