想了解php–stackOverflow如何在很短的时间内将他们的页面提交给搜索引擎?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于php页面传值的方法的相关问题,此外,我们还将为您介绍关
想了解php – stackOverflow如何在很短的时间内将他们的页面提交给搜索引擎?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于php页面传值的方法的相关问题,此外,我们还将为您介绍关于ASP.NET MVC – 如何抛出与StackOverflow类似的404页面、asp.net – 页面查看计数器像StackOverFlow、c# – Stackoverflow API响应格式、c# – StackOverflow如何优化显示问题的性能?的新知识。
本文目录一览:- php – stackOverflow如何在很短的时间内将他们的页面提交给搜索引擎?(php页面传值的方法)
- ASP.NET MVC – 如何抛出与StackOverflow类似的404页面
- asp.net – 页面查看计数器像StackOverFlow
- c# – Stackoverflow API响应格式
- c# – StackOverflow如何优化显示问题的性能?
php – stackOverflow如何在很短的时间内将他们的页面提交给搜索引擎?(php页面传值的方法)
我已经在stackoverflow上问了一个问题,并在google上搜索它的时间很短,它在第一页和第一个链接上,我想知道它如何能够很快提交网址并获得索引?
解决方法:
因为SO是最受欢迎的网站之一,有数千个链接指向,很多信任和经常更新的内容让谷歌机器人忙碌.
索引和抓取频率主要取决于您发布新内容的频率以及您的网站反向链接的方式.但即使使用常规的wp博客,您也可以将文章编入索引并在几分钟内排名.
ASP.NET MVC – 如何抛出与StackOverflow类似的404页面
这个工作
<HandleError()> _ Public Class BaseController : Inherits System.Web.Mvc.Controller ''# do stuff End Class
我也有我的404页面工作在一个Per-ActionResult基础上再次按预期工作.
这个工作
Function Details(ByVal id As Integer) As ActionResult Dim user As Domain.User = UserService.GetUserByID(id) If Not user Is nothing Then Dim userviewmodel As Domain.Userviewmodel = New Domain.Userviewmodel(user) Return View(userviewmodel) Else ''# Because of RESTful URL's,some people will want to "hunt around" ''# for other users by entering numbers into the address. We need to ''# gracefully redirect them to a not found page if the user doesn't ''# exist. Response.StatusCode = CInt(HttpStatusCode.NotFound) Return View("NotFound") End If End Function
再次,这是伟大的.如果用户输入的内容类似http://example.com/user/999(userID 999不存在),他们会看到相应的404页面,但URL不会更改(它们不会重定向到错误页面).
我无法理解这个想法
这是我遇到的问题.如果用户输入http://example.com/asdf-,他们将被踢到通用的404页面.我想做的是留下URL(IE:不重定向到任何其他页面),但只是显示“NotFound”视图,并将HttpStatusCode.NotFound推送到客户端.
例如,只需访问https://stackoverflow.com/asdf,您将在其中看到自定义的404页面,并查看保留的网址.
显然我错过了一些东西,但我无法想像出来.由于“asdf”实际上并不指向任何控制器,所以我的基本控制器类没有进入,所以我不能在那里的“HandleError”过滤器中.
先谢谢您的帮助.
注意:我绝对不想将用户重定向到404页面.我希望他们留在现有的URL,我想让MVC推送404 VIEW给用户.
编辑:
我也尝试过以下几点没有效果.
Shared Sub RegisterRoutes(ByVal routes As RouteCollection) routes.RouteExistingFiles = False routes.IgnoreRoute("{resource}.axd/{*pathInfo}") routes.IgnoreRoute("Assets/{*pathInfo}") routes.IgnoreRoute("{*robotstxt}",New With {.robotstxt = "(.*/)?robots.txt(/.*)?"}) routes.AddCombresRoute("Combres") ''# MapRoute allows for a dynamic UserDetails ID routes.MapRouteLowercase("UserProfile",_ "Users/{id}/{slug}",_ New With {.controller = "Users",.action = "Details",.slug = UrlParameter.Optional},_ New With {.id = "\d+"} _ ) ''# Default Catch All Valid Routes routes.MapRouteLowercase( _ "Default",_ "{controller}/{action}/{id}/{slug}",_ New With {.controller = "Events",.action = "Index",.id = UrlParameter.Optional,.slug = UrlParameter.Optional} _ ) ''# Catch All InValid (NotFound) Routes routes.MapRoute( _ "NotFound",_ "{*url}",_ New With {.controller = "Error",.action = "NotFound"}) End Sub
我的“NotFound”路线什么也没做.
解决方法
protected void Application_Error(object sender,EventArgs e) { Exception exception = Server.GetLastError(); // A good location for any error logging,otherwise,do it inside of the error controller. Response.Clear(); HttpException httpException = exception as HttpException; RouteData routeData = new RouteData(); routeData.Values.Add("controller","YourErrorController"); if (httpException != null) { if (httpException.GetHttpCode() == 404) { routeData.Values.Add("action","YourErrorAction"); // We can pass the exception to the Action as well,something like // routeData.Values.Add("error",exception); // Clear the error,we will always get the default error page. Server.ClearError(); // Call the controller with the route IController errorController = new ApplicationName.Controllers.YourErrorController(); errorController.Execute(new RequestContext(new HttpContextwrapper(Context),routeData)); } } }
asp.net – 页面查看计数器像StackOverFlow
考虑性能和可扩展性问题.
解决方法
UPDATE page_views SET counter = counter + 1 WHERE page_id = x if (affected_rows == 0 ) { INSERT INTO page_views (page_id,counter) VALUES (x,1) }
这样就可以为第一个视图运行2个查询,其他视图只需要1个查询.
c# – Stackoverflow API响应格式
如果我将http://api.stackoverflow.com/1.1/users/882993粘贴到浏览器地址栏中,我会得到正确的JSON响应:
{ "total": 1,"page": 1,"pagesize": 30,"users": [ { "user_id": 882993,"user_type": "registered","creation_date": 1312739131,"display_name": "Jack","reputation": 1926,"email_hash": "69243d90e50d9e0b3e025517fd23d1da","age": 23,"last_access_date": 1358087009,"website_url": "http://jtbrown.me.uk","location": "Birmingham,United Kingdom","about_me": "<p>Student.</p>\n","question_count": 68,"answer_count": 79,"view_count": 115,"up_Vote_count": 98,"down_Vote_count": 3,"accept_rate": 94,"association_id": "d64187a3-bf66-4a4d-8e87-6ef18f0397e3","user_questions_url": "/users/882993/questions","user_answers_url": "/users/882993/answers","user_favorites_url": "/users/882993/favorites","user_tags_url": "/users/882993/tags","user_badges_url": "/users/882993/badges","user_timeline_url": "/users/882993/timeline","user_mentioned_url": "/users/882993/mentioned","user_comments_url": "/users/882993/comments","user_reputation_url": "/users/882993/reputation","badge_counts": { "gold": 0,"silver": 7,"bronze": 34 } } ] }
如果我尝试在代码中执行相同的操作:
HttpWebRequest Request = WebRequest.Create("http://api.stackoverflow.com/1.1/users/882993") as HttpWebRequest; using (HttpWebResponse Response = Request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader Reader = new StreamReader(Response.GetResponseStream()); // Console application output StackWidget.Text = Reader.ReadToEnd(); }
我收到了回复:
�\b\0\0\0\0\0\0u�Ms�0���`8��Ӏ2�rl����#���J4��^\t#�p�g���j�����|�n�G/ڎ�7p����$�5\r���f�y�v�����\"F(���֛0���J�?{��������$���e�!T�-~+��@_p���j\fb�(�f�my��dt�ӄ�!AV\t����G'$\"؉i{;��X��5H9�z(�\"GQ<�]��TA9\b�Z��T��U%���;�n�-����*:ʚ��w�c��yU|P�m�S��M\r��?��O���@�m������\n'\b�}/�ь�.7E\a�*���uaDN@�k��N�L�zU\n�3�:DJ^S{����$K�\"�ɮ:f�.�)�P�\f�Qq\f�C�/�k*UN=�A\r�,7���.���p�9�3�jVT7��)ܬH\fYzW�4kGX�_|�AK��q�KU�GGw��^�j����D���7�\\��Ƴr,�N�yzno�F\ro�̄[�&i{afڵ��ٗ,���c\\~=l>6�\0U�F\0\0
解决方法
HttpWebRequest.AutomaticDecompression
属性自动完成.
var request = (HttpWebRequest)WebRequest.Create("http://api.stackoverflow.com/1.1/users/882993"); request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) using (var reader = new StreamReader(stream)) { var json = reader.ReadToEnd(); }
c# – StackOverflow如何优化显示问题的性能?
并且了解到stackoverflow使用C#.net我很高兴发现它.
我注意到在主页或问题部分,每当我刷新页面时.页面总是以可接受的速度向我返回最新信息.
我不知道你是怎么做到的.很抱歉这一系列问题很长.我试图了解数据检索,分页,性能等的最佳实践
我知道主页只返回有限数量的问题及其统计数据,但问题部分实际上返回了所有内容.
你如何优化它?
>对于主页,您是否总是获取最近问题的所有统计数据?所以你的查询类似于“按* date *创建限制20从问题顺序中选择*”?
所以*包含所有信息,包括问题标题,身份证,观点等?
你使用HttpContext.Current.Server.cache来帮助吗?
>对于这些问题,这更令人感兴趣.
你怎么做分页?
您是否始终只从数据库中获取特定页面的结果?
或者你抓住所有结果并将其存储到数据集中?然后你使用某种数据网格控件来帮助分页?
如果是后者,您如何维护要更新的数据?
解决方法
>页面完全由IIS的输出缓存缓存,无论用户身份验证如何
>仅针对匿名用户缓存的页面;注册用户查看最新内容
>部分页面的html为每个人缓存; httpruntime.cache用于此目的
主页由三个缓存的html片段组成 – 最近的问题,最近的标签,最近的徽章 – 每个都有不同的持续时间.
问题列表页面将缓存特定排序/标签过滤器的所有问题的ID(Int32 []),使得分页变得微不足道.还完成了对统计数据的进一步缓存(例如,问题计数,相关标签计数).
将为匿名用户完全缓存问题详细信息页面,而注册用户将查看最新商品.此外,侧面的相关问题将缓存到磁盘更长的持续时间.
虽然我们尝试尽可能地缓存整个页面,但我们确实在页面顶部显示用户信息 – 某些部分无法缓存.
所以看看缓存就像一个谜题 – 我的所有请求之间可以安全地共享哪些部分?根据费用,我的所有请求必须共享哪些部分?
我们今天的关于php – stackOverflow如何在很短的时间内将他们的页面提交给搜索引擎?和php页面传值的方法的分享已经告一段落,感谢您的关注,如果您想了解更多关于ASP.NET MVC – 如何抛出与StackOverflow类似的404页面、asp.net – 页面查看计数器像StackOverFlow、c# – Stackoverflow API响应格式、c# – StackOverflow如何优化显示问题的性能?的相关信息,请在本站查询。
本文标签: