2013-07-17 28 views
0

響應在此上下文中不可用。 我該如何解決這個問題,我需要一些幫助,請 我試圖解決這個問題,但我不能 的網站能正常工作在我的本地主機上,但是當我把它上傳到主機上不起作用 人幫助我,請'/'應用程序中的服務器錯誤4

{ 

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

你高估了我們閱讀你的思維的能力。 –

+1

附加代碼,提供有關您的頁面的更多信息,嘗試更多地解釋您的問題 – wudzik

+0

可能存在不同的場景,請考慮部署環境並共享您的代碼。如果可能的話,通過引入try catch塊並寫入文件並將其發送到生產環境來修改代碼。 – kbvishnu

回答

3

如錯誤所述,您無法訪問Application_Start中的Response對象。 檢查(並最好發佈)Global.asax代碼Application_Start方法。

+0

我的代碼是要在這裏張貼我應該怎麼做? – Lelo

+0

@hussein檢查這個http://stackoverflow.com/questions/6624210/response-is-not-available-in-this-context – kbvishnu

+0

@VeeKayBee,你真的要張貼鏈接?你只是反對它。 –

0

爲什麼它在本地計算機上並不起作用遠程可能是因爲在本地網站IIS 經典管道模式而遠程下運行的原因 - 下集成的管線模式

您可以通過切換到傳統流水線模式來解決問題:here's how

希望這會有所幫助。

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> 
+0

這是我的global.asax – Lelo

+0

有人幫忙嗎? – Lelo

相關問題