简体   繁体   English

如何从xml重定向到aspx页面?

[英]how to redirect from xml to aspx page?

I am actually trying to understand why this site that I am looking at redirects from an xml file to an aspx file. 我实际上是想了解为什么我正在查看的该网站从xml文件重定向到aspx文件。 So when I type in the location of the xml file it redirects to the home page which is an aspx file?? 因此,当我输入xml文件的位置时,它会重定向到作为aspx文件的主页? I understand you can redirect hostnames but I dont understand why an xml file redirects ? 我知道您可以重定向主机名,但我不明白为什么xml文件重定向? Does this make sense? 这有意义吗? In fiddler it returns a httpcode 301 when trying to load the xml file and the next line is a httpcode 200. You dont actually get to see the contents of the xml it goes straight to the aspx page. 在fiddler中,当尝试加载xml文件时,它返回一个httpcode 301,而下一行是一个httpcode200。您实际上并没有看到xml的内容,它直接进入了aspx页面。

I suspect you need to not deliver the XML as an XML file. 我怀疑您不需要将XML作为XML文件提供。 Instead, embed it on an HTML or ASPX page and use something like Alex Gorbetchev's syntax highlighter to display the XML. 而是将其嵌入HTML或ASPX页面,并使用Alex Gorbetchev的语法突出显示工具显示XML。 You can then have logic on the page to handle the redirection. 然后,您可以在页面上有逻辑来处理重定向。

Maybe is only URL REWRITING. 也许只是URL重写。 This can be done using Global.asax file... 这可以使用Global.asax文件来完成...

  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

      Dim thepage As String = HttpContext.Current.Request.Path

      If InStr(1, thepage , "/sitemap.xml", vbTextCompare) Then
        Server.Transfer("sitemap.aspx") '' mask the redirection

        ''Response.Redirect("sitemap.aspx") '' or make the redirection
      End If

  end Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM