Menu

Request is not available in this context

Help
2008-10-25
2019-12-21
  • Nobody/Anonymous

    Hi all

    I have set up bugtracker.net 2.9.8 in IIS7 on Windows Server 2008 and configured as suggested in the readme.html file - the only config i changed was the absoluteurlprefix and connection string - the other settings i left as default. When i try to access the site I get the following error:

    Request 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: Request is not available in this context

    Source Error:

    Line 379:        {
    Line 380:            context = asp_net_context;
    Line 381:            Request = context.Request;
    Line 382:            //Response = context.Response;
    Line 383:            //Server = context.Server;

    Source File: c:\sites\projects.softwarehouse.co.zw\App_Code\util.cs    Line: 381

    My c# is bearable but not great. Is this a bug or a configuration problem? Can anyone help?

    Thanks a lot
    James

     
    • Corey Trager

      Corey Trager - 2008-10-25
       
    • Corey Trager

      Corey Trager - 2008-10-25

      You would be doing me a big favor if you were to try out code changes I send you.   I don't have the ability to test my code.   Can you email me directly at ctrager@yahoo.com?

       
    • Corey Trager

      Corey Trager - 2008-10-25

      Change the set_context method in util.cs so that it reads as follows.  Let me know if it works for you.

              public static void set_context(HttpContext asp_net_context)
              {
                  context = asp_net_context;
                 
                  try
                  {
                      Request = context.Request;
                  }
                  catch(Exception e)
                  {
                      Util.write_to_log (e.Message);
                  }

              }

       
    • Corey Trager

      Corey Trager - 2008-11-02

      This is fixed in version 2.9.9

       
  • Denis Cilliers

    Denis Cilliers - 2012-01-01

    I just installed 3.5.5 and this bug has returned.

    The log files posts  are as follows, first one is before the update above the next is after the update above.  So the error has returned

    2011-12-31 18:03:04  caught exception in util.set_context:Request is not available in this context
    2011-12-31 18:10:38  Request is not available in this context

     
  • Denis Cilliers

    Denis Cilliers - 2012-01-01

    The offending line of code is in the Global.asax.

    btnet.Util.set_context(HttpContext.Current); // required for map path calls to work in util.cs

    The reason for the error is because you are calling an object that does not exist yet. 

    It appears they moved the order of the object creation higher up the stack and hense this object is not available in the app_start

     
  • Denis Cilliers

    Denis Cilliers - 2012-01-01

    move the function call to later in the process

    public void Application_BeginRequest(Object sender, EventArgs e)
        {
            btnet.Util.set_context(HttpContext.Current); // required for map path calls to work in util.cs
           
        }

     
  • Denis Cilliers

    Denis Cilliers - 2012-01-01

    Umm nope still not solved, ignore these comments above the log file still reports;

    2011-12-31 19:03:03  Request is not available in this context
    2011-12-31 19:03:04  Request is not available in this context

     
  • parmenpj

    parmenpj - 2014-07-24

    EDIT: thought I had a fix, but spoke to soon. Can't delete.

     

    Last edit: parmenpj 2014-07-24
  • Corey Trager

    Corey Trager - 2019-12-21

    It only took me eleven years but I think I fixed this in the release I just posted, 367.

     

Log in to post a comment.