views:

173

answers:

2

Basically we moved from IIS 5 to IIS 7 and I am trying to update some of our old COM objects to .NET by rewriting them in C#. What I am have so far is a Classic ASP page calling the COM+ object and then I am trying to do a simple redirect within the COM+ object (this is just for testing purposes, it's not what the object will do eventually).

My problem/question is, why does the redirect call not work properly? Am I doing something wrong or can you not redirect within a COM+ object? All that happens is a blank white page comes up and if I check the IIS logs, I see no errors.

Here is my code so far:
In Classic ASP (the call to COM+)

Set oBankReg = CreateObject("BVSRegistration.SignIn")  
oBankReg.GetBankId(bankid)

Code in C# COM object:

using System;  
using System.Web;  
using System.Text;  
using System.EnterpriseServices;  
using System.Collections.Generic;  
using System.Runtime.InteropServices;  

[assembly: ApplicationName("BVSRegistration")]  
[assembly: Description("COM+ upgrade of the BVSRegistration VB6 SignIn.cls.")]  
[assembly: ApplicationActivation(ActivationOption.Server)]  
[assembly: ApplicationAccessControl(false, AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)]  

namespace BVSRegistration  
{   
    public class SignIn : ServicedComponent       
    {    
        public void GetBankId(string bankid)  
        {  
            HttpContext.Current.Response.Redirect("http://www.google.com");  
        }  
    }  
}  

Any ideas? Thanks

+2  A: 

ASP.Net's Response.Redirect uses the ASP.Net stack, which is not in use in an ASP page.

You need to either switch away from ASP or call ASP's Response.Redirect.

SLaks
+2  A: 

HttpContext will only be set in the context of an ASP.NET setting. Since you are calling from ASP classic, it won't be bound to the actual request/response stream.

What you should do is indicate whether or not to redirect from your COM+ object, and call classic ASP's equivalent to Redirect.

Randolpho
So, for example, return a string with the site I'd potentially want to redirect to and then Response.Redirect(returnedSite) in classic ASP?
ajdams
Yes, exactly. :)
Randolpho
I figured it out, thanks a bunch for your help everyone!
ajdams