如何在每日报价网站中使用 ASP.NET 路由
下午好,
一位客户有兴趣创建一个 ASP.NET 2.0 网站,其目的是提供“每日报价”。他希望静态内容页面上的引号全部附加到同一母版页。报价页面必须按一定的顺序查看,并且站点浏览器在浏览站点时不能查看除起始页面之外的任何其他页面。即大家进入站点时必须进入001.aspx页面。
两个问题: 1. 内容页面将由客户端使用 Excel 数据源和创建每个报价页面的合并过程来创建,例如。 001.aspx、002.aspx 等。这对我来说充其量是笨重的。 ASP.NET 动态数据会是更好的解决方案吗?
- 我对 ASP.NET 路由和 URL 重写整体来说还是个新手。如何设置路由表以确保用户始终在同一入口页面上输入站点,并创建路由表以使 default.aspx 解析为 001.aspx?
谢谢, 席德
Good Afternoon,
A client is interested in creating an ASP.NET 2.0 website whose purpose is to serve up a "quote of the day". He wants the quotes on static content pages all attached to the same master page. The quote pages must be viewed in a certain sequence, and site browsers cannot view any other pages than the starting page when browsing to the site. That is, everyone must go to page 001.aspx when entering the site.
Two Questions:
1. The content pages are going to be created by the client using an excel data source and a merge process by which each quote page is created eg. 001.aspx, 002.aspx etc. This seems clunky to me at best. Would ASP.NET Dynamic Data be a better solution here?
- I'm new to ASP.NET Routing and URL Rewriting as a whole. How would I setup a route table to ensure that users always entered the site on the same entry page, and create a route table such that default.aspx resolves to 001.aspx?
Thanks,
Sid
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 Excel 工作表作为数据源,并通过分页从所述数据源获得的结果集来处理查看“报价页面”。
如果您的客户关心 SEO,他必须认识到,他对只有一个入口页面的要求违背了他的“一引用一页是 SEO 友好”的原则。
我认为区分人类用户和搜索机器人的努力不值得。
无论如何,googlebot 能够使用 URL 参数对页面进行索引,从而在不生成静态内容的情况下实现 SEO 友好(其他机器人也应该如此)。
可能的解决方案
为了允许搜索机器人为您的报价建立索引,您需要一个报价日期的查询参数。
如果您想强制人类用户(黑客不算;-))仅在当前日期之前进入网站,您可以检查浏览器字符串,并将任何不被识别为搜索机器人的浏览器重定向到当前日期(如果引荐来源网址是)不等于前一个日期。
这个解决方案应该会给你一个合理的结果,而不需要太多的开销。
I would suggest to use the excel sheet as a data source and handle viewing the 'Quote pages' by paging through the result set obtained from said data source.
If your client is concerned about SEO, he must recognize that his requirement to have only one entry page defeats his One-Quote-One-Page-Is-SEO-friendly.
I don't think the effort to distinguish between a human user and a search bot is worth it.
Anyway googlebot is capable of indexing pages with URL parameters thus allowing to be SEO friendly without generating static content (other bots should be as well).
Possible solution
To allow search bots to index your Quotes you have a query parameter for the date of the Quote.
If you want to enforce human users (hackers don't count ;-)) to enter the site only by the current date you check the browser string and redirect any browser not being know as a search bot to the current date if the referer is not equal to the previous date.
This solution should give you a reasonable result without too much overhead.