2013-07-17 4 views
0

Ответ в этом контексте недоступен. , как я могу решить эту проблему мне нужна помощь, пожалуйста, я пытался решить, но я не мог работы сайта должным образом на моем локальном хосте, но когда я загрузить его на хост его не работает кто-нибудь помочь мне, пожалуйстаОшибка сервера в '/' Application 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

может быть другой сценарий, просто подумайте о среде развертывания и поделитесь своим кодом. Если возможно, измените код, введя блок catch try и напишите в файл и отправьте его в производственную среду. – kbvishnu

ответ

3

Как говорится в ошибке, вы не можете получить доступ к объекту Response в Application_Start. Проверьте (и предпочтительно пост) код в 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

Смежные вопросы