proxypage: filetype / mimetype
Hello!
This is my first post here. Actually, im not really a programmer, but im trying to figure out some stuff. Hopefully with your help.
Im in need of a kind of "proxypage", that will rewrite some lines of html.
While doing that, i also need to process all included files like .js and images.
I want to read an HTML file. All links will be rewritten, so a src="/images/blank.gif" will be something like src="proxypage.aspx?proxiepath=/images/blank.gif"
The proxypage should stream this file, and display it as normal. But how? all I get is a bunch of charakters on the screen, so i assume it has something to do with a mimetype. How can I get this mimetype, and how can I set it :)
The code that im using to stream is the following:
(beware, im not a developer! )
proxiedURL would be the name of the file, so : http://xx.xx.xx.xx/images/blank.gif, http://xx.xx.xx.xx/js/custom.js or the html file i want to rewrite.
Code:
webRequest = webRequest.Create(New Uri(proxiedURL))
webresponse = webRequest.GetResponse()
ProxyStream = New StreamReader(webresponse.GetResponseStream())
While (Not ProxyStream.EndOfStream)
regel = ProxyStream.ReadLine
' DO SOME STUFF WITH REGEXP TO REWRITE HTML LINES
Response.Write(regel)
End While
Re: proxypage: filetype / mimetype
Hello,
I have to put my suspicious hat on here...
Why exactly are you doing this? Whose website are you pulling content from, and do you have permission to do this?
Gary
Re: proxypage: filetype / mimetype
haha, i can imagine.
Its going to be within a closed environment. Im getting search results from an appliance, and need to hide certain fragments. This cannot be done through the appliance itself. Usually i would do the adjustments in xslt, but in this case i can't. So the only think i have, is already generated html.
I get the search query, send it through to the appliance (with a certain parameter extra). The results I get back, and hide some fragments. The appliance cannot be accessed directly by the users, only by this proxypage.
Re: proxypage: filetype / mimetype
Hello,
Are you able to show us the Regex that you are using?
Given that you are using Response.Write (which isn't the best way) you are emitting HTML directly into the response stream for the page, a response stream that will already contain the opening <html> tags etc, you are going to need to make sure that you are only emitting content HTML, not other "top level" html.
Gary
Re: proxypage: filetype / mimetype
Also, bear in mind that depends at which point you do the Response.Write, it will appear as the first thing in the response stream.
You might be better off using a Literal Control, and writing the HTML in that.
Gary
Re: proxypage: filetype / mimetype
i dont have the regexp ready yet.. im baaaadd in this! :D
What is a better way of doing this, instead of using response.write ?
ow, you are mentioning Literal Control. I 'll have to read into this tonight.
(i hoped for a small example. haha)
thnx
Re: proxypage: filetype / mimetype
As a simple example:
Code:
Me.Literal1.Text = "<table><tr><td>test</td></tr></table>"
Gary