问题描述
我有一个面向公众的业余爱好网站,每天有大约 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) 让我可以对标记进行一些控制-和 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 的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!