• <tfoot id='3h8fI'></tfoot>
      <bdo id='3h8fI'></bdo><ul id='3h8fI'></ul>

    <small id='3h8fI'></small><noframes id='3h8fI'>

    1. <legend id='3h8fI'><style id='3h8fI'><dir id='3h8fI'><q id='3h8fI'></q></dir></style></legend>
      <i id='3h8fI'><tr id='3h8fI'><dt id='3h8fI'><q id='3h8fI'><span id='3h8fI'><b id='3h8fI'><form id='3h8fI'><ins id='3h8fI'></ins><ul id='3h8fI'></ul><sub id='3h8fI'></sub></form><legend id='3h8fI'></legend><bdo id='3h8fI'><pre id='3h8fI'><center id='3h8fI'></center></pre></bdo></b><th id='3h8fI'></th></span></q></dt></tr></i><div id='3h8fI'><tfoot id='3h8fI'></tfoot><dl id='3h8fI'><fieldset id='3h8fI'></fieldset></dl></div>

      1. 将经典 ASP 请求路由到 .NET - SEO 重定向

        时间:2023-10-06
            <bdo id='gytIw'></bdo><ul id='gytIw'></ul>

              <i id='gytIw'><tr id='gytIw'><dt id='gytIw'><q id='gytIw'><span id='gytIw'><b id='gytIw'><form id='gytIw'><ins id='gytIw'></ins><ul id='gytIw'></ul><sub id='gytIw'></sub></form><legend id='gytIw'></legend><bdo id='gytIw'><pre id='gytIw'><center id='gytIw'></center></pre></bdo></b><th id='gytIw'></th></span></q></dt></tr></i><div id='gytIw'><tfoot id='gytIw'></tfoot><dl id='gytIw'><fieldset id='gytIw'></fieldset></dl></div>
              <tfoot id='gytIw'></tfoot>
                <tbody id='gytIw'></tbody>

                  <small id='gytIw'></small><noframes id='gytIw'>

                • <legend id='gytIw'><style id='gytIw'><dir id='gytIw'><q id='gytIw'></q></dir></style></legend>
                  本文介绍了将经典 ASP 请求路由到 .NET - SEO 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我们正在用 .NET 3.5 解决方案替换旧的经典 asp 网站.

                  We are replacing an old classic asp website with a .NET 3.5 solution.

                  我们需要将所有经典 ASP 请求重定向到 aspx 页面(即 contactus.asp,现在可能会路由到/contact-us/default.aspx).我想要的是请求访问 global.asax,这样我就可以做类似

                  We need to redirect all of the classic ASP requests to aspx pages (i.e. contactus.asp, may now route to /contact-us/default.aspx). What I woudl like is for the requests to hit global.asax so I can do something like

                  If url == "bob.asp"
                      Response.Status = "301 Moved Permanently";
                      Response.AddHeader("Location", SiteConfig.SiteURL + redirectUrl);
                  End If
                  

                  有两种不优雅的解决方案.

                  There are two inelegant solutions.

                  A) 放置一个 global.asa 文件并通过该文件进行路由.

                  A) Place a global.asa file and do the routing through that.

                  B) 将 asp 文件映射到 .NET 引擎.很好,但是如果我们需要在我们的站点上托管经典的 asp 站点,IIS 会将请求发送到错误的位置.

                  B) Map asp files to the .NET engine. Great, but then if we need to host classic asp sites on our sites IIS will be sending the requests to the wrong place.

                  我在这里找到了一个不错的解决方案

                  I found a nice solution here

                  http://forums.asp.net/p/1202225/3458901.aspx

                  这表明这样的事情可能会起作用......

                  Which stated something like this may work...

                  <buildProviders>
                  
                  <add extension=".php" type="System.Web.Compilation.PageBuildProvider" />
                  
                  </buildProviders>
                  <httpHandlers>
                  
                  <add verb="*" path="*.php" type="System.Web.UI.PageHandlerFactory" validate="True" />
                  
                  </httpHandlers>
                  

                  此示例适用于 php,但我认为同样适用于 asp.但是,在示例中将 .php 更改为 .asp 并将标签放置在 web.config 的正确部分之后,我没有任何乐趣(实际上是 500 服务器错误).

                  This example was for php but I assume the same thing would work for asp. However after changing .php to .asp in the example and placing the tags in the correct part of the web.config I'm having no joy (a 500 server error actually).

                  任何人都可以对此有所了解或给我一个优雅的解决方案.

                  Can anyone shed any light on this or give me an elegant solution.

                  感觉上述解决方案不适用于 php 或 asp,因为 IIS 将在请求到达 .NET 引擎之前对其进行路由.

                  Had a feeling the above solution wouldnt work for php or asp as IIS will have routed the request before it gets to the .NET engine.

                  提前致谢

                  史蒂夫

                  推荐答案

                  @EdSF 在评论中指出我的答案是错误的.我难以置信地使用 Firebug 进行了检查,事实上,这是错误的.

                  Big edit: I was pointed by @EdSF in the comments that the answer was wrong. In disbelief I checked using Firebug, and, in fact, it was wrong.

                  您需要使用 Context.Response.RedirectLocation 才能使状态码起作用.

                  You need to use Context.Response.RedirectLocation for the status code to work.

                  我在 global.asax 中也是这样做的:

                  I'm doing the same in global.asax:

                  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
                      Dim fullOriginalpath As String = Request.Url.ToString.ToLower
                  
                      If (fullOriginalpath.Contains("/verarticulo.asp?articuloid=")) Then
                          Context.Response.StatusCode = 301
                          ''// this does not work, returns a 302
                          ''//Context.Response.Redirect("/noticias/" + getIDFromPath(fullOriginalpath))
                  
                          ''// this does right way
                          Context.Response.RedirectLocation = "/noticias/" + getIDFromPath(fullOriginalpath)
                          Context.Response.End()
                      ElseIf (fullOriginalpath.Contains("/archivo.asp")) Then
                          Context.Response.StatusCode = 301
                          Context.Response.RedirectLocation = "/archivo/" 
                          Context.Response.End()
                      ElseIf (fullOriginalpath.EndsWith("/default.asp")) Then
                          Context.Response.StatusCode = 301
                          Context.Response.RedirectLocation = "/"
                          Context.Response.End()
                      End If
                  End Sub
                  

                  如果您使用 II6,您唯一需要做的就是配置此 ISAPI 过滤器这样:

                  The only thing you have to do if you are using II6 you have to configure this ISAPI filter in this way:

                  文件是c:windowsmicrosoft.netframeworkv2.0.50727aspnet_isapi.dll

                  这篇关于将经典 ASP 请求路由到 .NET - SEO 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Server.CreateObject 在经典 ASP 中失败 下一篇:将 ASP.NET 与 ASP 混合

                  相关文章

                • <tfoot id='ucbEO'></tfoot>
                  <legend id='ucbEO'><style id='ucbEO'><dir id='ucbEO'><q id='ucbEO'></q></dir></style></legend>
                  • <bdo id='ucbEO'></bdo><ul id='ucbEO'></ul>

                • <i id='ucbEO'><tr id='ucbEO'><dt id='ucbEO'><q id='ucbEO'><span id='ucbEO'><b id='ucbEO'><form id='ucbEO'><ins id='ucbEO'></ins><ul id='ucbEO'></ul><sub id='ucbEO'></sub></form><legend id='ucbEO'></legend><bdo id='ucbEO'><pre id='ucbEO'><center id='ucbEO'></center></pre></bdo></b><th id='ucbEO'></th></span></q></dt></tr></i><div id='ucbEO'><tfoot id='ucbEO'></tfoot><dl id='ucbEO'><fieldset id='ucbEO'></fieldset></dl></div>

                    <small id='ucbEO'></small><noframes id='ucbEO'>