C#/ASP.Net Web Development

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

C#/ASP.Net Web Development

Post by Xaos »

Has anyone done any web dev in C#/ASP.Net? I was just kind of wondering how it worked. I really like C#, and am considering doing some web dev in it, but not sure how everything gets wired like I know with PHP. IE can you just upload the C# files to the server and they work? DO you have to install something additional into the server? Technical details like that is what seems to elude me. Also, what was your experience with it?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: C#/ASP.Net Web Development

Post by Jackolantern »

I have used both ASP.NET and ASP.NET MVC, although I prefer to the later (Alain prefers the former). How you actually set up an ASP.NET web application into production becomes more clear when you install the correct web server for .NET: IIS. However, that is only for production. For development, simply select to debug your application from within Visual Studio. VS has IIS Lite included in it and it works seamlessly inside of VS. This whole setup is quite amazing if you are coming from the world of PHP. You just select to debug your app, and it runs just like a Windows app. And it has been years since I have deployed a .NET web app, but I think it is almost as simple as one button-press today.
The indelible lord of tl;dr
User avatar
srachit
Posts: 291
Joined: Sat Jan 05, 2013 6:10 pm

Re: C#/ASP.Net Web Development

Post by srachit »

Just another question I'd like to add, do you have to have a windows server for it to work?


edit:
another question is it posssible to do C# programming on linux. I hear very good things about it, but because I'm mainly a linux based user these days I'm not sure if I can still make apps using C# or is it like objective c confined to the apple ecosystem
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: C#/ASP.Net Web Development

Post by Xaos »

Ah gotcha, thanks alot Jacko!

How would you set up design and whatnot? Are there specific things to use using .Net or would you just use the normal HTML/CSS/JS/etc.?


Srachit, you could use Mono or WINE.


http://monodevelop.com/
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: C#/ASP.Net Web Development

Post by Jackolantern »

srachit wrote:Just another question I'd like to add, do you have to have a windows server for it to work?


edit:
another question is it posssible to do C# programming on linux. I hear very good things about it, but because I'm mainly a linux based user these days I'm not sure if I can still make apps using C# or is it like objective c confined to the apple ecosystem
Yes, as Xaos said, there is Mono an Wine. Mono has a...sketchy...track record. It is always several versions behind official .NET (I think LINQ really threw Mono a curve-ball in .NET 3.0), and some .NET devs (such as Alain and myself) hate it. I would never load a production site onto Mono.
Xaos wrote:How would you set up design and whatnot? Are there specific things to use using .Net or would you just use the normal HTML/CSS/JS/etc.?
Ahhh, this is where ASP.NET splits. Time to take a history lesson to understand two of the three forms of ASP.NET:

Back in the year 2000 when .NET was being designed, not many devs actually knew web development that well. Web devs were in a tiny minority of all devs, since "web apps" were a pretty new thing, and they were seen as a bit of a novelty since really only PHP had done decently in that space at that time (ASP Classic did not fair as well) and Javascript was mostly being used to add a snow flake effects to pages and was considered a toy language.

Part of the .NET Initiative was to bring web apps to the world of Windows Forms developers. Thus marked the creation of ASP.NET. It was centered around the idea of "Web Forms", which were very similar to Windows Forms, where you placed intelligent controls on a form and wrote a Code Behind in C# to react to events.

Fast forward eight years. Some devs who cut their teeth on web forms had since learned web development in depth through such MVC frameworks as Ruby on Rails. Javascript was also claiming the throne from its humble beginnings to the premier programming language of the world. But ASP.NET Web Forms write most of the JS for you, and many devs were frustrated by the "hands off the client" methodology of Web Forms. They wanted to write their own clients to create rich Internet applications with HTML, Javascript and CSS. Thus marked the creation of ASP.NET MVC.

ASP.NET MVC is built on top of the existing core of ASP.NET, but builds it up in MVC structure, following the lead of popular frameworks such as Rails, Symfony, Zend, etc. You build the client-side yourself in HTML, JS and CSS with the help of server-side helper classes as part of the framework.

There is another, newer form of ASP.NET called ASP.NET Web Pages which won't be treated here since it is designed to offer a .NET solution for small, one-off webpage apps that one would typically use vanilla PHP for.

Neither ASP.NET Web Forms or ASP.NET MVC is better than the other. Nor is MVC a replacement for Web Forms. Devs of different backgrounds will find they cotton to one form or the other. Web Forms has also done a ton to enable rich client-side scripting alongside the intelligent Server Controls (particularly from .NET 4.0 and on). Devs with a .NET background will likely have a better experience with ASP.NET Web Forms while devs from a PHP, Ruby on Rails, etc. background will likely fair better with ASP.NET MVC.

This is the way I personally look at it: If you are designing intranet sites that will be connecting to company databases to do data manipulation, go Web Forms. The Server Controls will do a lot of this for you out of the box. If you are making an app that has heavy client-side scripting, or you are making a SPA (Single Page Application), go MVC. But that is just my opinion, as I come from a background of PHP for the most part (I actually started before PHP in .NET, but never did any web development with it back then).
The indelible lord of tl;dr
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: C#/ASP.Net Web Development

Post by Xaos »

Ah, it appears I'm going to be using MVC then. I'm going to be making the game i've been talking about, and wanted to use .Net. Thanks for hte help :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: C#/ASP.Net Web Development

Post by Jackolantern »

That would be my choice for a game as well.

-sits patiently and waits for Alain, the ardent Web Forms fan-
The indelible lord of tl;dr
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: C#/ASP.Net Web Development

Post by a_bertrand »

Hahahaha.... Shall I answer? Shall I not?... I can't resist... no I really can't

As our Jacko said there is indeed 2 path, or actually even more, but let's say two main path:
- Web Form
- MVC

Web form is based on the idea of "GUI components" where you will basically compose your pages out of them. Think about buttons, lists, trees and such. If you want to build your page out of components (smart one or very simple one), then Web forms will offer you a lot.

MVC is based on the idea of the way oversold design pattern with the same name. It would work easier maybe if you come from the Java, Ruby and PHP (with frameworks) world. However the development with MWC IS slower than with Web Form.

I would also tend to think that the MVC part of ASP.NET offers less options and is actually more a honey pot than an actual true solution, but that's a personal opinion.

Before you choose, you would need to think about what you want to make as software and how you want to develop it. Also it is always better to know both roads before choosing, so make some tests and have at least a good idea of the differences. Web forms is extremely powerful, but you should be able to develop your own components yourself otherwise you will be somehow blocked to the limited options MS gives out of the box.

For running it on Linux: forget it. Wine will most likely NOT be enough, and Mono is simply not usable in production. Renting a VPS or Shared Window server is cheap enough to not be needed to run your code on Linux. If you really need to then, the best option is to create a virtual machine, install windows on the virtual machine on your Linux machine and run ASP.NET within this windows machine.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: C#/ASP.Net Web Development

Post by Xaos »

Aha, I was waiting for the reply. I'll look at both, then, and kind of decide which I prefer. With Xamarin/Mobile dev, I've been working use like a GUI interface to design using components/widgets and whatnot, so I may have some more familiarity with that.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: C#/ASP.Net Web Development

Post by hallsofvallhalla »

I work with .Net websites for 80% of my day. Matter of fact yesterday I was working on a .Net site for 13 hours straight! Started to see the Matrix for a bit :P

I use Web Forms mainly. I have no interest in MVC whatsoever. Web Forms work for everything I need and in a way that is simple and elegant enough to see no need to change how I do things. That is my preference though as there is not a better or worse. I currently use more of a web service approach.

Front end is 90% HTML, CSS, Javascript. I use very little asp.net as it is too much like PHP with all the refresh stuff going on. I basically capture all my data through Javascript then bundle it up with Json and send it to a C# webservice on the backend using Ajax. .Net 3.5 and above has built in Json serialization so how things work is truly magically and there is nothing even close to being as awesome.

I have a Javascript class for a person

Code: Select all

var Person = {
FirstName: Joe,
LastName: Smith,
Hair: Black
} 
I can then send that Javascript object via ajax to a webservice

Code: Select all

$.ajax({
                type: "POST",
                url: "ajaxscripts/GetPeople.aspx/AddPerson",
                data: "{Data:" + JSON.stringify(Person) + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                   document.getElementById("Result").innerHTML = "Successfully added " + msg.d.FirstName);
                }
            });
This send the object to a webform on the back end called GetPeople and goes to the Method(function) AddPerson and turns the Json object into an instance of the Person class in C# automatically! I can even return the class back quite naturally

Code: Select all

 [WebMethod]
        public static Person AddPerson(Person Data)
        {
            this.FirstName = Data.FirstName;
            this.LastName = Data.LastName;    
            this.Hair = Data.Hair;
            return Data;
       }
To me that is as good as it gets. I can run an entire page passing classes back and forth with little effort without a single refresh. Maybe something like this should be my next Tutorial series?
Post Reply

Return to “General Development”