locked
The name 'Request' does not exist in the current context RRS feed

  • Question

  • I used the following code the get the url of privouse page/view. It works well in SharePoint 2010 with reference to the system.web namespace.

    prePage = Request.QueryString["source"];
    if (prePage == null)
             prePage = "/nbep";

    Now, I am working in SharePoint 2013. I got an error "The name 'Request' does not exist in the current context". I know when I add a web part, the namespace is "webpart" vs "user control" in SharePoint 2010. I just wonder if anyone know how to accomplish the need in SharePoint 2013.

    Many thanks.  

    Wednesday, September 11, 2013 8:41 PM

Answers

  • wouldn't a sure-thing be to just reference the full HttpContext.Current.Request.QueryString["source"]? Doubt that thing will ever not exist...

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

    • Proposed as answer by Sohel Rana Thursday, September 12, 2013 12:58 AM
    • Marked as answer by eg10013 Thursday, September 12, 2013 1:23 PM
    Wednesday, September 11, 2013 8:45 PM

All replies

  • wouldn't a sure-thing be to just reference the full HttpContext.Current.Request.QueryString["source"]? Doubt that thing will ever not exist...

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

    • Proposed as answer by Sohel Rana Thursday, September 12, 2013 12:58 AM
    • Marked as answer by eg10013 Thursday, September 12, 2013 1:23 PM
    Wednesday, September 11, 2013 8:45 PM
  • HttpContext.Current.Request.QueryString["source"] remove the error. I will test if the function work tomorrow. Thank you very much.

    Wednesday, September 11, 2013 10:12 PM