简体   繁体   中英

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. So when I type in the location of the xml file it redirects to the home page which is an aspx file?? I understand you can redirect hostnames but I dont understand why an xml file redirects ? 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.

I suspect you need to not deliver the XML as an XML file. Instead, embed it on an HTML or ASPX page and use something like Alex Gorbetchev's syntax highlighter to display the XML. You can then have logic on the page to handle the redirection.

Maybe is only URL REWRITING. This can be done using Global.asax file...

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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