ASP.NET - 用户可以创建文章(如博客)的网站的最佳方法
我是 ASP.NET 新手,但总体来说对编程并不陌生。 我正在创建一个商业网站,我希望允许管理员添加新文章(文章由文本、图像和各种属性(例如类别)组成)。 我正在尝试确定最佳的操作方式。该网站是商业网站,因此 SEO 是主要考虑因素。这意味着我希望每个网址都是“唯一的”。也就是说,如果有人导航到一篇有关浣熊的文章,他应该被重定向到 www.mysite.com/articles/raccoons。这意味着 - 我无法让一个页面能够像 AJAX 一样动态加载相应的文章(必须使用深层链接)
那么我究竟该如何做到这一点呢?假设管理员输入文本、上传图像并设置文章属性。我创建一个新的子文件夹,将图像保存到服务器(我知道将图像保存到数据库是一个很大的禁忌),将它们的地址保存到数据库中,并将内容本身保存到数据库中。但现在怎么办?
如何创建实际页面?
是否有创建新 aspx 文件的功能?那么它对应的cs文件呢?或者使用aspx是不明智的吗?也许是纯 html?但它如何与我网站的母版页配合使用呢?或者也许只是创建一个通用 aspx 文件的另一个副本,该文件根据参数填充了一篇文章?
在我深入研究之前,我想知道什么是“最聪明”的方法。
I'm an ASP.NET newbie, but not so new at programming in general.
I'm creating a commercial website, and I want to allow an admin to add new articles (an article consists of text, images and various properties such as category).
I am trying to decide the optimal Modus Operandi. This site is commercial, so SEO is a major consideration. This means that I want each url to be "unique". That is, if someone navigates to an article about raccoons, he should be redirected to www.mysite.com/articles/raccoons. This means - I can't have one page that loads the appropriate article dynamically a-la AJAX (gotta use deep-linking)
So how exactly do I do this? suppose the admin entered his text, uploaded the images and set the article properties. I create a new subfolder, save the images to the server (I understand that saving images to a DB is a big no-no), their addresses in a DB, and the content itself to the DB. But now what?
How do I go about creating the actual page?
Is there a function for creating a new aspx file? then what about its corresponding cs file? Or is it unwise to use aspx? Maybe plain html? but then how does it work with my site's master page? Or maybe just create another copy of a general aspx file which is populated with an article according to a parameter?
I would like to know what is the "smartest" approach before I dive in too deep.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您可以考虑使用 ASP.Net MVC。您需要的更像是内容管理系统而不是博客,正如您提到的管理员将添加文章。
通过使用 ASP.Net MVC,您在那里有一个非常干净的实现,您的 url 将保留在 SEO 所需的位置,您不必动态创建 aspx 页面,但框架将允许您处理类文件中的新 url 。
You can Consider ASP.Net MVC for this. What you need is more like a Content Management System rather than a Blog, as you mentioned an administrator will add articles.
By Using ASP.Net MVC, you have a very clean implementation there, your urls will stay as you need it for SEO, You dont have to create aspx pages on the fly but the framework will let you deal with new urls from your class files.