I am implementing a COM component using .net for a few outdated components for a server migration task.
The old component was used to receive an image path on the current server, convert it to a jpeg and save the converted image in the same path.
This is trivial to do in .net, however my main problem is obtaining the server context. I am not sure how to do either one of the following:
The component is being called within a class ASP page (yes, unfortunately!) using:
Server.CreateObject("Component.Class")
Is there anyway in the implementing .net code that I can obtain a reference to the Server
object that created the component? I was hoping that if I could obtain a reference to the server, I could then obtain the appropriate context to write back to the response stream.
I have worked this out, obtaining a few clues for the internet and google. Thought I should post this in case anyone else has the same problem.
Obtaining the server context was a matter of including the following references:
Working out the above was the hardest thing :-) After that, its very simple to reference your server and other intrinsic ASP objects:
COMSVCSLib.AppServer aspServer = new COMSVCSLib.AppServer();
COMSVCSLib.ObjectContext oc = aspServer.GetObjectContext();
ASPTypeLibrary.Server server = (ASPTypeLibrary.Server)oc["Server"];
You can do the same with with other ASP objects such as Request and Response.
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.