Tutorial :Should i write in C# first then port to web?



Question:

I wanted to write a website but i know almost no web programming. I looked at ASP.NET and i wanted to know. Should i write my app in straight C# with a form and many buttons to test each page/component? then port or have someone help me port? or should i do it from straight ASP.NET from the start?

-edit- I edited the below after the first 6 answers so they may look strange

I am thinking i can get more done if i just use C# and sqlite since i can write scrap and test code quicker and get a prototype up faster. ASP.NET would take a lot of time for simple basic things.

NOTE: I will not be doing heavy form coding. Just simple IO to put and pull data from a db.


Solution:1

Just start with asp.net.

WinForms and WebForms don't translate well. Especially if you are learning asp.net


Considering your update to the question, this is still the right way to go. WinForms != WebForms != MVC or whatever else. Knowing one doesn't translate to knowing another one.


Solution:2

If you don't know web programming, then whatever you do in straight C# is going to port very poorly to ASP.NET. You need to understand the web first.


Even given your comment, my suggestion stands. Learn web programming first. You can go create a separate DAL and business logic layer first, if you like; you can even create those using Test Driven Development. But before you touch the UI, you need to understand what the web is about, or you'll make some mistakes you'll regret.


Solution:3

The correct way to do this is to create a component (library) in C# that deals with all the database work (reading and storing of data and validation of that data). You can build a winform on top of that to make sure that your library works.

Once that is done, consume the library from your ASP.NET page and you won't need to worry about the lower-level logic that you've already tested.

Don't try to port your winform code to the web as this will not work nicely.


Solution:4

If this is your first time working with C#, you may even be better suited to get started by completely separating your code layer from the presentation layer. I started by playing around with UI's in both web and win forms apps rather than learning great coding practices and code separation. If you're starting from scratch, you can learn code separation first and not worry about what the UI is going to do.

So in short, neither. Start with good code separation between the database and the custom data classes and go from there.


This is by no means meant to be a perfect illustration of how to have good code separation, but more of a bulleted list of how you could go about getting started. You'd want to search for dependency injection, repository patterns, etc. for more of a best practice view...

For example, say you want to create a contact manager application. You know that you'll have code for inserts, updates, and deletes along with some searching and general lists of contacts.
  1. I would start by creating your DB with all of the fields you'll know you want.
  2. I would then add some dummy data to the database.
  3. Now I would create the data layer in my application. Probably best that this is a separate project all together that compiles to a simple DLL.
  4. Now that you have your data classes built for storing contact information, it is time to create your layer that will actually go and get the data. Goto your solution and add a new project that will compile into a DLL.
  5. Make sure the DB is available to your code.
    a. LINQ2SQL
    b. Enterprise Library
  6. Create functions for adding, editing, and deleting contacts. Most likely the parameter would be the Contact object that you created in #3.
  7. Create functions for searching and returning lists of contacts. This should return a List that gets created in #3 or something along these lines...
  8. Add whatever UI layer on top of this by referencing both DLL's in your UI project (could be console, web, win...)


Solution:5

Write all of your backend code, and use a unit test framework, to make certain it works.

Once you have all but the display code done, then you can look at doing the display, then just pick which technology you want to use.


Solution:6

I would say write straight to ASP.NET. I don't think the learning curve will be that bad for you if you already know C# on WinForms, and the databinding model in ASP.NET is different in enough aspects that I think you would benefit from writing it just once.


Solution:7

If you're planning at all to make a go at it as an actual programmer and you're intending on creating a website, please go ahead and learn html and css before you jump over into C#. There are plenty of great, free resources out on the web.

Learn html and css and then try out Asp.Net MVC to ease yourself into dynamic web development.


Solution:8

as the others said start in asp.net first. i would recommend first writing a little test app which in a small space will do the things that you require the big app to do.

there are a few stumbling blocks in the differences between winforms and asp.net pages. so the above should help you get over some of them.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »