我应该首先用C#写入然后移植到网络吗?

时间:2022-03-26 18:35:03

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?

我想写一个网站,但我几乎不知道网络编程。我看了ASP.NET,我想知道。我应该用直接的C#编写我的应用程序,并使用表单和许多按钮来测试每个页面/组件吗?然后港口或有人帮我端口?或者我应该从一开始就从直接的ASP.NET做到这一点?

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

-edit-我在前6个答案后编辑了下面的内容,所以看起来很奇怪

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.

我想如果我只是使用C#和sqlite我可以做得更多,因为我可以更快地编写废料和测试代码并更快地获得原型。 ASP.NET需要花费大量时间来处理简单的基本事情。

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

注意:我不会做重型编码。只需简单的IO即可从数据库中提取和提取数据。

8 个解决方案

#1


Just start with asp.net.

刚开始使用asp.net。

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

WinForms和WebForms翻译得不好。特别是如果你正在学习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.

考虑到您对问题的更新,这仍然是正确的方法。 WinForms!= WebForms!= MVC或其他任何东西。知道一个不会转化为知道另一个。

#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.

如果您不了解Web编程,那么无论您在C#中执行什么操作都将非常糟糕地移植到ASP.NET。您需要先了解网络。


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.

即使你发表评论,我的建议仍然存在。首先学习网络编程。如果愿意,您可以先创建一个单独的DAL和业务逻辑层;你甚至可以使用测试驱动开发创建那些。但是在你触摸用户界面之前,你需要了解网络的内容,否则你会犯一些你会后悔的错误。

#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.

执行此操作的正确方法是在C#中创建一个组件(库),用于处理所有数据库工作(读取和存储数据以及验证该数据)。您可以在其上构建一个winform,以确保您的库有效。

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.

完成后,从ASP.NET页面使用库,您不必担心已经测试过的低级逻辑。

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

不要试图将您的winform代码移植到Web上,因为这样做不会很好。

#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.

如果这是您第一次使用C#,您可能更适合通过将代码层与表示层完全分离来开始使用。我开始在网络和赢取表单应用程序中玩UI,而不是学习优秀的编码实践和代码分离。如果您从头开始,您可以先学习代码分离,而不必担心UI将要做什么。

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. 我将首先创建您的数据库,其中包含您想知道的所有字段。

  3. I would then add some dummy data to the database.
  4. 然后我会向数据库添加一些虚拟数据。

  5. 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.
  6. 现在我将在我的应用程序中创建数据层。可能最好的是,这是一个单独的项目,它们汇编成一个简单的DLL。

  7. 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.
  8. 现在您已经构建了用于存储联系信息的数据类,现在是时候创建实际可以获取数据的图层了。转到您的解决方案并添加一个将编译为DLL的新项目。

  9. Make sure the DB is available to your code.
    a. LINQ2SQL
    b. Enterprise Library
  10. 确保您的代码可以使用该数据库。一个。 LINQ2SQL b。企业图书馆

  11. Create functions for adding, editing, and deleting contacts. Most likely the parameter would be the Contact object that you created in #3.
  12. 创建用于添加,编辑和删除联系人的功能。参数很可能是您在#3中创建的Contact对象。

  13. Create functions for searching and returning lists of contacts. This should return a List that gets created in #3 or something along these lines...
  14. 创建用于搜索和返回联系人列表的功能。这应该返回一个在#3中创建的List或者这些行中的某些内容......

  15. Add whatever UI layer on top of this by referencing both DLL's in your UI project (could be console, web, win...)
  16. 通过在UI项目中引用两个DLL来添加任何UI层(可以是控制台,Web,win ...)

#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.

除了完成显示代码之外,您可以查看显示内容,然后选择要使用的技术。

#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.

我想直接写ASP.NET。如果你已经知道WinForms上的C#,我认为学习曲线不会对你有害,并且ASP.NET中的数据绑定模型在很多方面都不同,我认为你只需编写一次就可以从中获益。

#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.

如果你计划作为一名真正的程序员去做,并且你打算创建一个网站,请在跳转到C#之前继续学习html和css。网上有很多优质的免费资源。

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

学习html和css然后尝试使用Asp.Net MVC来简化自己的动态Web开发。

#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.

正如其他人所说,先从asp.net开始。我建议先写一个小测试应用程序,在一个小空间里做你需要大应用程序做的事情。

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.

winforms和asp.net页面之间存在一些绊脚石。所以上面应该可以帮助你克服其中一些。

#1


Just start with asp.net.

刚开始使用asp.net。

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

WinForms和WebForms翻译得不好。特别是如果你正在学习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.

考虑到您对问题的更新,这仍然是正确的方法。 WinForms!= WebForms!= MVC或其他任何东西。知道一个不会转化为知道另一个。

#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.

如果您不了解Web编程,那么无论您在C#中执行什么操作都将非常糟糕地移植到ASP.NET。您需要先了解网络。


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.

即使你发表评论,我的建议仍然存在。首先学习网络编程。如果愿意,您可以先创建一个单独的DAL和业务逻辑层;你甚至可以使用测试驱动开发创建那些。但是在你触摸用户界面之前,你需要了解网络的内容,否则你会犯一些你会后悔的错误。

#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.

执行此操作的正确方法是在C#中创建一个组件(库),用于处理所有数据库工作(读取和存储数据以及验证该数据)。您可以在其上构建一个winform,以确保您的库有效。

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.

完成后,从ASP.NET页面使用库,您不必担心已经测试过的低级逻辑。

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

不要试图将您的winform代码移植到Web上,因为这样做不会很好。

#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.

如果这是您第一次使用C#,您可能更适合通过将代码层与表示层完全分离来开始使用。我开始在网络和赢取表单应用程序中玩UI,而不是学习优秀的编码实践和代码分离。如果您从头开始,您可以先学习代码分离,而不必担心UI将要做什么。

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. 我将首先创建您的数据库,其中包含您想知道的所有字段。

  3. I would then add some dummy data to the database.
  4. 然后我会向数据库添加一些虚拟数据。

  5. 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.
  6. 现在我将在我的应用程序中创建数据层。可能最好的是,这是一个单独的项目,它们汇编成一个简单的DLL。

  7. 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.
  8. 现在您已经构建了用于存储联系信息的数据类,现在是时候创建实际可以获取数据的图层了。转到您的解决方案并添加一个将编译为DLL的新项目。

  9. Make sure the DB is available to your code.
    a. LINQ2SQL
    b. Enterprise Library
  10. 确保您的代码可以使用该数据库。一个。 LINQ2SQL b。企业图书馆

  11. Create functions for adding, editing, and deleting contacts. Most likely the parameter would be the Contact object that you created in #3.
  12. 创建用于添加,编辑和删除联系人的功能。参数很可能是您在#3中创建的Contact对象。

  13. Create functions for searching and returning lists of contacts. This should return a List that gets created in #3 or something along these lines...
  14. 创建用于搜索和返回联系人列表的功能。这应该返回一个在#3中创建的List或者这些行中的某些内容......

  15. Add whatever UI layer on top of this by referencing both DLL's in your UI project (could be console, web, win...)
  16. 通过在UI项目中引用两个DLL来添加任何UI层(可以是控制台,Web,win ...)

#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.

除了完成显示代码之外,您可以查看显示内容,然后选择要使用的技术。

#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.

我想直接写ASP.NET。如果你已经知道WinForms上的C#,我认为学习曲线不会对你有害,并且ASP.NET中的数据绑定模型在很多方面都不同,我认为你只需编写一次就可以从中获益。

#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.

如果你计划作为一名真正的程序员去做,并且你打算创建一个网站,请在跳转到C#之前继续学习html和css。网上有很多优质的免费资源。

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

学习html和css然后尝试使用Asp.Net MVC来简化自己的动态Web开发。

#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.

正如其他人所说,先从asp.net开始。我建议先写一个小测试应用程序,在一个小空间里做你需要大应用程序做的事情。

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.

winforms和asp.net页面之间存在一些绊脚石。所以上面应该可以帮助你克服其中一些。