.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Page Methods querystrings are null

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net


I'm having problems with accessing querystring params in my page method. Everywhere I read it says you can access querystrings just fine, but when I try it just returns null, what's the problem?

same problem I found -  http://stackoverflow.com/questions/1765188/access-to-querystring-session-from-a-static-method


thanks in advance

View Complete Post

More Related Resource Links

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Page Methods and Yahoo UI


Hello people,
I'm constructing an application with Page Methods and YAHOO UI.
I'm Not using Update Panels because Page Methods are faster than Update Panel.

You can post your experiences with this feature of ASP.NET Extensions and vantages of using this type of architecture.

Thanks a lot.

Flávio Malaquias
Asp.Net Senior Developer

Page.FindControl Causing Null Reference Exception


Hi guys,

I developed a page in VWD 2008 and it works perfectly locally, but when I deployed it on the server every Page.FindControl() call is causing the NullReference Exception "Object reference not set to an instance of an object. " Can anyone help me out? Code is below


Mike Marshall

            For i As Integer = 1 To 10
                If (CType(Page.FindControl("last_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("first_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("dob_" & i), TextBox).Text.Length > 0) Then
                    Dim person_entry(7) As String
                    person_entry(0) = info_list.Count - 1
                    person_entry(1) = CType(Page.FindControl("last_" & i), TextBox).Text
                    person_entry(2) = CType(Page.FindControl("first_" & i), TextBox).Text
                    person_entry(3) = CType(Page.FindControl("dob_" & i), TextBox).Text
                    person_entry(4) = CType(Page.FindControl("appear_" & i), TextBox).Text
                    person_entry(5) = CType(Page.FindControl("mental_" & i), TextBox).Text
                    person_entry(6) = CType(Page.FindControl("behave_" & i), TextB

how to redirect user to login page if session is null

i have 2 page,1.login.aspx ---  2.welcome.aspxin my login.aspx im storing username into sesssion as below:Session["usernm"] = txtUsername.Text;in my welcome.aspx  pagein page_load event if (Session["usernm"]==null)        {            Response.Redirect("Login.aspx");        }----- here if i manulally paste the url ( http://localhost:4125/Loginado/welcome.aspx) it should go to  login.aspx for user credentialsbut its going directly to welcome.aspx  page.

Methods and New Page

Hi i got a method Called ConstructTable() .Now when i click a button it needs to open a Created  Webform  and do the method i created.How i this possible

Null reference message Custom Error page

how come a Null session value that is called, doesn't get directed to the Custom Error Page?

page version history gives error: "value cannot be null. parameter key: name"

Hello, I'm have customized my homepage in SharePoint Designer 2010. I want to go back to a previous version, so I right click on the aspx file in sharepoint designer and choose "version history". When I do that I get this message: There was an error connecting to the server. The server error encountered is "Value cannot be null. Parameter name: key" What should I do in order to revert my aspx page to a previous version ?

Page Methods



In my page I am using page methods to call an webmethod in the server side.If suppose there is an exception in that web method I want to redirect to some other page,but i m not able to do that.

can anyone help me on this?




how to use page methods in content page


hi all,

I wish to create a website based on ajax functionality using Master and Content pages.

I want to use page method or xmlhttprequest object to check  some validations in registration form,which is a content page of my website. Is it possible to work so or is there any other method to do it.
The code I'v written using page method in  normal aspx page working fine but it is not working in contnet page.

 Please let me know the solution..

thanks in advance

SPContext.Current.Web.CurrentUser null in application page on 2008 r2 server

With my current situation I have:
a wss3 development environment on a 2003 R2 server
then a production 2008 r2 server.

For some reason on the 2008 server the SPContext.Current.Web.CurrentUser object is null for users who are site collection administrators but may not have permission to log into the server itself; however, on the 2003 R2 server the code works fine for those users.
When googling around, I had seen something about nt permissions on the bin folder sometimes being and issue until asp.net cache picks up the dll but this is a page in the _layouts directory and the code is in the .aspx page itself. It works fine for me as a system administrator on either machine.

Any suggestions? Thanks.

How to call page methods from a Master page ?



I have written web methods in code behind and I'm able to call them using PageMethods.(method name) in an ordinary aspx page.

If I'm trying to call the webmethods in a master page using PageMethods.(method name), it is throwing a jscript error pagemethods

is undefined.

My code is like this:


    public static string[] GetTimes()
        dt1 = DateTime.Now;
        string[] a = { };
        a[0] = dt1.ToUniversalTime().Subtract(new TimeSpan(5, 0, 0)).ToString("HH:mm");
        a[1] = dt1.ToUniversalTime().ToString("HH:mm");
        a[2] = dt1.ToUniversalTime().AddHours(0d).ToString("HH:mm");
        a[3] = dt1.ToUniversalTime().AddHours(8d).ToString("HH:mm");
        return a;

<script language="javascript">

  function UpdateNYCTime() {

      PageMethods.GetTimes(times, OnSucceeded);

 function OnSucceeded(result, userContext, methodName) {
   $get('spanNYC').innerHTML = result[0].toString(); 




Any Suggestions ? If I cannot call page methods from master page page, is there any another way of calling them ?




URITemplate Inconsistency... QueryStrings Parameters Sometimes Null - Sometimes Not...

Hello all,

I've encountered a strange inconsistecy in the way WCF parses URIs?

My contract looks like:

    <OperationContract()> _
    <WebGet(UriTemplate:="{CampaignID}/objects?page={Page}&pagesize={PageSize}")> _
    Sub getObjects(ByVal CampaignID As String, ByVal Page As String, ByVal PageSize As String)

    <OperationContract()> _
    <WebInvoke(Method:="POST", UriTemplate:="{CampaignID}/objects")> _
    Sub addObject(ByVal CampaignID As String)

getObjects cannot be run without parameters - in this case, it'll return "Method Not Allowed".

However - if addObject is removed ... getObjects CAN run without parameters (Null will be passed in for Page/PageSize).

Why is there an inconsistency in the way WCF processes query string parameters - is there a way to fix this inconsistency... i

Page Methods...security?


hey all,

need some help with page methods.

I'm using page methods in my web app, and now in few of those methods I need to check whether the request is ehm....secure?I have url parameters on my page, so each time page methodis called I check if those parameters are present and validate them against a DB, and then do the other stuff.

now...is there a way to implement this mechanic into each page methodI'm using, instead writing code inside each WebMethod ?

so what I have now is

        public static string MyMethod(string value)
//1.checking if parameters passed are valid

//2.if true then performing actions, else just returning error


what I want to do is get rid of 1. inside the method, and have it like a wrapper or something, so I could do the same validation on each page method I want.

thanks for help


Use Silvelight Form as Edit page ClientContext.Current is null



I've created a custom content type and set a xap as edit form and new form.

this edit/new form of course gets open in the classic SharePoint Dialog.

the problem I have is that the ClientContext.Current is null in this context (Silverlight in Dialog)

I get a context when I host this xap in the Silverligth Web Part

what's wrong ?

SharePoint 2007: Custome aspx Page Development: Null ReferenceException in Microsoft.SharePoint.Admi


Hi All,

I have developed a user control, aspx page containing that user control and deployed that to SharePoint through WSP deployment. The problem I am facing is that When i load my page it works fien, however when i post back the page (by clicking the Submit button ,y page crashes and gives following error)

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

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:

HTTPCONTEXT return null in a DLL in a sharepoint 2010 custom application page?


am having a application page abc.cs file in a class library and abc.aspx in the _forms folder of 14\template  in sharepoint 2010 env.

also i am having another DLL[ say xyz] which  has  2 classes  and some methods.

now i am accessing a  website page with a  querystring http://servername:4444/hoem.aspx?sid=5353535dsadsaddada

I want to get this query string in the abc's onload event and adding it to the http cookie. Now my reqmnt is i want to access the query string using httpcontext.current.request.querstring["sid"]in the second DLL [xyz].

when  tried to access the request.querystring() thr HTTPCONTEXT throws/returns  NULL .

i wonder, why this httpcontext returns null.

how can i access the querystring().

any help is appreciated



The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend