1

I have the following lines of code:

SPList thisList = oWeb.Lists[new Guid(Request.Url.QueryString).Get("List")];
SPListItem thisItem = thisList.GetItemById(int.Parse(Request.QueryString["ID"]));

But the Request.Url.QueryString does not resolve correctly. I have included the following using statements:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web;
using System.Reflection;
using Microsoft.SharePoint.Utilities;

When I right click I usually get a "Resolve" menu option if I have forgotten to put in a usings statement at the top but that does not appear.

Request QueryString Not Resolving

How can I use Request to get the parameters passed into a SharePoint application page?

  • Looks like your application page is not deriving from LayoutsPageBase? – Nadeem Yousuf Feb 13 '15 at 11:22
  • @NadeemYousuf my application page is deriving from LayoutsPageBase but I also tried deriving from System.Web.UI.Page with no progress. – motionpotion Feb 13 '15 at 11:36
3

The answer is:

HttpContext.Current.Request.QueryString

Also make sure your page inherits from either LayoutPageBase or UnsecuredLayoutPageBase which are the base classes for application pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.