问题描述
我有一个面向公众的爱好网站,每天有大约 3000 名独立访问者,它是用经典的 ASP 编写的,急需改造和重新设计.我已经意识到升级到 ASP.net 是实现 ASP 中对业余爱好者来说太难的功能的最佳方式(使用 RSS 提要、身份验证和用户配置文件),但我很想得到一旦我通过了重新设计/升级,就会陷入困境.
I have a public facing hobby site that gets about 3000 unique visitors a day, written in classic ASP that is in bad need of a revamp and redesign. I've faced the realization that an upgrade to ASP.net is the best way to go to implement features that are just too hard in ASP for the hobbyist (consuming RSS feeds, authentication and user profiles) but which I'm keen to get stuck into once I get past the redesign/upgrade.
但是,我一直不确定该走哪条路:Web 表单或 MVC - 再加上似乎总是有一些新版本即将发布,这似乎值得坚持以改进学习曲线.所以我花了几个小时阅读有关 WebForms 的内容,然后阅读一些告诉我考虑 MVC 可能会更好的东西,然后阅读有关 MVC 并想知道它是否真的适合我正在尝试做的事情.
But, I have been paralysed with uncertainty about which way to go: Web Forms or MVC - plus the fact that there always seems to be some new release about to launch that seems like it would be worth holding out for to improve the learning curve. So I spend hours reading about WebForms then read something that tells me I might be better off thinking about MVC, then read about MVC and wonder whether it actually suits what I'm trying to do.
教程和入门网站都没有真正讨论什么对传统的旧静态信息网站(不是目录或用户内容驱动)有效.
None of the tutorials and starter sites really talk about what works well for sites that are traditional old static information sites (not catalogues or user-content-driven).
我的网站大约有 75% 的静态信息页面很少更改.然而,ASP 脚本在所有这些页面的用户界面中是必不可少的——动态或随机选择设计元素(如标题照片)或根据一年中的某天或随机提供特定的侧边栏框.
My site is about 75% static information pages that rarely change. However, the ASP scripting is essential in the user interface on all those pages - dynamically or randomly picking design elements (like a header photo) or providing a particular sidebar box based on the day of the year or at random.
我拥有的脚本类型包括随机选择并显示页面的 30 个标题图像之一的脚本、根据一年中的哪一天显示文本和链接的脚本、允许我使用的脚本将特定搜索关键字声明为与特定页面的内容相关,并在页面加载时将其作为文本预加载到搜索输入框中.
The kind of scripting I have is things like a script to randomly pick and display one of 30 header images for the page, a script to display text and links based on what day of the year it is, a script that allows me to declare a particular search keyword as being relevant to the content for a particular page and having that pre-loaded as the text in the search input box when the page loads.
对于其余大部分页面,它们是关于显示数据的.其中一些是小型记录集(关于一年中这一特定日子的重要信息的年历类型信息),我将其保存并从页面本身的 Array 变量中提取.其他人从 Access 数据库中提取信息,这些信息变化很少,以至于我从来没有费心在网站上实时实现 CUD 功能(以及保护它的必要角色和身份验证),但只需离线更新数据库并上传它以实时发送更改.
For most of the rest of the pages, they are about displaying data. Some of them are small recordsets (almanac type information about what is significant about this particular day of the year) and I save it and pull it from an Array variable in the page itself. Others pull information from an Access database that changes rarely enough that I've never bothered implementing CUD functionality live on the site (and the necessary roles and authentication to secure it), but just update the database offline and upload it to send the changes live.
使用 ASP.net,我会很好地迁移到 SQL Server 并构建实时管理页面.我不需要坚持使用 Access.
With ASP.net, I would be fine moving to SQL Server and building live administration pages. I don't need to stick with Access.
但是,我更习惯于编写原始 HTML 和 CSS,并且我发现 WebForms(尤其是 Viewstate 和事件/回发)在概念上是一个挑战.尽管它似乎更适合带有我习惯的一些服务器端代码的文件系统中的静态页面.
But, I'm more used to writing raw HTML and CSS and I'm finding WebForms (especially Viewstate and events/postbacks) a challenge to get my head around conceptually. Even though it seems to fit more with the static page in a file system with some server-side code that I'm used to.
另一方面,MVC 似乎非常适合手工编码设计,但所有内容都是从数据库中提取的.
On the other hand, MVC seems to be well suited to lovingly hand-coded design, but where everything gets pulled from a database.
你会推荐什么?我应该将所有静态页面拉入数据库并通过 MVC 中的文章"视图提供它们吗?
What would you recommend? Should I pull all the static pages into a database and serve them through an "article" view in MVC?
我不是专业的开发人员 - 所以这与我的简历上看起来最好的东西无关.我只是在寻找(a)对于来自经典 ASP 中的 VBScript 内联表达式的人来说学习曲线最少的东西,以及(b)最适合我的网站所做的事情,以及(c)让我对标记有一些控制权-up 和 CSS.
I'm not a professional developer - so it's not about what will look best on my resume. I'm just looking for what will (a) have the least learning curve for someone coming from VBScript inline expressions in classic ASP and (b) what best suits what my site does and (c) lets me have some control over the mark-up and CSS.
推荐答案
一定要使用 MVC,特别是如果你更喜欢 HTML/CSS 人的话.对于一个基本上是静态的网站来说,回传没有任何优势,而且你需要几个月的时间才能了解页面生命周期(我还没有遇到过一个开发人员,他在编写了 6 个月的代码后就掌握了这个生命周期.)
Definitely go MVC, especially if you're more comfortable as an HTML/CSS guy. Postbacks offer no advantage for a site that is largely static, and it will take months for you to get your head around the page lifecycle (I have yet to meet a developer who was a master of the lifecycle after 6 months of coding in it.)
将 ASP 经典站点转换为 MVC 基本上涉及将 HTML 和 ASP 标记移动到视图中,并使用路由机制复制现有 URL.您需要升级脚本以使用一些更现代的功能,但我想这应该相当简单.
Converting an ASP classic site to MVC will basically involve moving your HTML and ASP tags into Views, and replicating your existing URL's using the routing mechanisms. You'll need to upgrade your scripts to use some more modern functionality, but that should be fairly straightforward I would imagine.
我不同意在 MVC 中所有内容都从数据库中提取的想法——这与架构有点无关.我已经在 MVC 框架中编写了 100% 的静态站点并且喜欢它:)
I do disagree with the idea that in MVC everything is pulled from the database - that's a bit irrelevant to the architecture. I've coded 100% static sites in MVC frameworks and loved it :)
我的经验法则是:MVC 用于网站,WebForms 用于企业 Web 应用程序 - 也许."
My rule of thumb is trending towards this: "MVC for websites, WebForms for enterprise web applications - maybe."
这篇关于关于使用 ASP.net WebForms 或 MVC 的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!