locked
Error Rendering Control RRS feed

  • Question

  • User511514143 posted

    I created a custom control (dll). When I drag n drop it on the page I get the following message.

    "An unhandled exception has occurred. Response in not available in this context". I googled it but I found nothing usefull. 

    Wednesday, July 15, 2009 8:25 AM

Answers

  • User-644392667 posted

    lol, great question! The answer - NONE!

    ;)

    Basically the Request object that you get handed when you are writing from within an aspx page (for example) IS the HttpContext.Current.Request. It is just that you don't need to specify it since you are in the HttpContext.Current at the time. You need to specify it when you are using it somewhere else because you might not (possibly) be in an HttpContext...

    m

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 15, 2009 3:51 PM

All replies

  • User-644392667 posted

    I suspect that your control has some code that goes Response.QueryString[...] or some such. What it is telling you is that it can not directly access the Response object. You need to reference it through HttpContext.Current

    You need to change your code to say something like

    System.Web.HttpContext.Current.Response.Querystring[...]

    In other words, replace simple Response with the HttpContext.Current.Response

    Hope that helps,

    m

    Wednesday, July 15, 2009 9:18 AM
  • User511514143 posted

    Οκ thanks that worked. But what's the different between Request.QuerySTring() and HttpContext.Current.Request.QueryString()???

    Wednesday, July 15, 2009 1:28 PM
  • User-644392667 posted

    lol, great question! The answer - NONE!

    ;)

    Basically the Request object that you get handed when you are writing from within an aspx page (for example) IS the HttpContext.Current.Request. It is just that you don't need to specify it since you are in the HttpContext.Current at the time. You need to specify it when you are using it somewhere else because you might not (possibly) be in an HttpContext...

    m

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 15, 2009 3:51 PM