【问题标题】:Response.Redirect in a COM+ Object Called from Classic ASP Page从经典 ASP 页调用的 COM+ 对象中的 Response.Redirect
【发布时间】:2010-03-23 00:24:23
【问题描述】:

基本上,我们从 IIS 5 迁移到 IIS 7,我正在尝试通过用 C# 重写它们来将我们的一些旧 COM 对象更新到 .NET。到目前为止,我所拥有的是一个调用 COM+ 对象的经典 ASP 页面,然后我试图在 COM+ 对象中进行简单的重定向(这只是为了测试目的,这不是对象最终会做的事情)。

我的问题/问题是,为什么重定向调用不能正常工作?我做错了什么还是不能在 COM+ 对象中重定向?所发生的只是出现一个空白页,如果我检查 IIS 日志,我看不到任何错误。

到目前为止,这是我的代码:
在经典 ASP 中(对 COM+ 的调用)

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

C# COM 对象中的代码:

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");  
        }  
    }  
}  

有什么想法吗?谢谢

【问题讨论】:

  • 另外一点:该类也必须扩展 ServicedComponent。那是我遇到的另一个问题。所以在这个例子中 BVSRegistration : ServicedComponent

标签: c# com iis-7 asp-classic


【解决方案1】:

HttpContext 只会在 ASP.NET 设置的上下文中设置。由于您是从 ASP 经典调用,它不会绑定到实际的请求/响应流。

您应该做的是指示是否从您的 COM+ 对象重定向,并调用经典 ASP 的 Redirect 等价物。

【讨论】:

  • 因此,例如,返回一个字符串,其中包含我可能希望重定向到的站点,然后在经典 ASP 中使用 Response.Redirect(returnedSite)?
【解决方案2】:

ASP.Net 的Response.Redirect 使用 ASP.Net 堆栈,该堆栈未在 ASP 页面中使用。

您需要离开 ASP 或致电 ASP 的Response.Redirect

【讨论】:

    猜你喜欢
    • 2010-11-14
    • 1970-01-01
    • 2011-09-29
    • 2014-07-13
    • 2011-06-23
    • 2011-08-04
    • 1970-01-01
    • 2016-08-12
    • 2011-12-05
    相关资源
    最近更新 更多