Can't set Response object in ASP Classic

2019-07-28 06:22发布

问题:

This line:

set Response = nothing

Fails with the error

"Microsoft VBScript runtime  error '800a01b6'

Object doesn't support this property or method: 'Response' "

Now, I can think of any number of reasons why the engine might not want to let me do such a seemingly silly thing, but I'm not sure how a missing method could be stopping me.

EDIT: Here is an example of what I'd like to do with this.

class ResponseBufferEphemeron
    private real_response_
    private buffer_

    private sub class_initialize
        set real_response_ = Response
    end sub

    private sub class_terminate
        set Response = real_response_
    end sub

    public function init (buf)
        set buffer_ = buf
        set init = me
    end function

    public function write (str)
        buffer_.add str
    end function
end class

function output_to (buf)
    set output_to = (new ResponseBufferEphemeron).init(buf)
end function

dim buf: set buf = Str("Block output: ") ' My string class '
with output_to(buf)
    Response.Write "Hello, World!"
end with 

Response.Write buf ' => Block output: Hello, World! '

回答1:

You can't set the Response to nothing.

The ASP Response object is used to send output to the user from the server.

What are you trying to do? If you're trying to end the Response to the user, use

Response.End


回答2:

Well, I found the answer here: http://blogs.msdn.com/b/ericlippert/archive/2003/10/20/53248.aspx

So we special-cased VBScript so that it detects when it is compiling code that contains a call to Response.Write and there is a named item in the global namespace called Response that implements IResponse::Write. We generate an efficient early-bound call for this situation only.



标签: asp-classic