0

在这种情况下没有响应。我该如何解决这个问题我需要一些帮助我试图解决它但我无法在我的本地主机上正常工作但是当我将它上传到主机时它不起作用任何人请帮助我

{

Response is not available in this context.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Response is not available in this context.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): Response is not available in this context.]
   System.Web.HttpContext.get_Response() +8820296
   ASP.global_asax.Application_Start(Object sender, EventArgs e) +54

[HttpException (0x80004005): Response is not available in this context.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +2731054
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +128
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295
   System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231

[HttpException (0x80004005): Response is not available in this context.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8929163
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333
}
4

3 回答 3

3

正如错误所说,您无法Response访问Application_Start. 检查(并最好发布)Global.asax中的代码以获取该Application_Start方法。

于 2013-07-17T12:38:44.380 回答
0

它在您的本地机器上工作而不能远程工作的原因可能是因为该网站在本地运行在 IIS经典管道模式下,而在远程 - 在集成管道模式下

您可以通过切换到经典管道模式来解决问题:方法如下。

希望这可以帮助。

于 2013-07-17T13:55:54.787 回答
0
<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
       Application.Add("Visitor",0);
      HttpContext.Current.Response.Redirect("Default.aspx");
        // Code that runs on application startup
        //string MyCounter = ConfigurationManager.AppSettings["Counter"];
        //Application.Add("Count",MyCounter);
       // Counter.UpdateAddOneRecord("VisitorCounter");
    }

    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown
      //  ConfigurationManager.AppSettings["Counter"] = Application["Count"].ToString();


    }

    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started
        int visitor = int.Parse(Application.Get("Visitor").ToString());
        visitor++;
        Application.Set("Visitor", visitor);
        Counter.UpdateAddOneRecord("VisitorCounter");
        // Arabic
        //Session.Add("Lng", "ar-IQ");
        //Session.Add("Theme", Neaimy_MSB.Neaimy_Lib.getTheme());
        //Session.Add("MrqDir", "Left");
        //Session.Add("Dir", "rtl");
        //Session.Add("MrqDirInverse", "ltr");
        //Session.Add("AddComment", "flase");

        //Session.Add("Lng", "ar-IQ");
        Session.Add("Lng", "en-GB");
        Session.Add("Theme", Neaimy_MSB.Neaimy_Lib.getTheme());
        Session.Add("MrqDir", "Right");
        Session.Add("Dir", "ltr");
        Session.Add("MrqDirInverse", "rtl");
        Session.Add("AddComment", "flase");

        //  int count =int.Parse(Application.Get("Count").ToString());
        //int count =int.Parse(Application.Get("Count").ToString());
        //count++;
        //Application.Set("Count",count);
    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.
        int Visitor = int.Parse(Application.Get("Visitor").ToString());
        Visitor--;
        Application.Set("Visitor", Visitor);


    }

</script>
于 2013-07-17T22:10:54.233 回答