Click here to Skip to main content
15,895,656 members
Articles / Web Development / ASP.NET

Unlimited Query string - ASP.NET

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
1 Sep 2010CPOL2 min read 38.6K   284   13   14
Unlimited Query string Solution for Web Application.

Introduction

Query string is one of the primary parameter passing techniques for Web Application.

Query string has some limitation in terms of query string length; this length depends on the browser.

To handle the query string length limitation, there are few solutions –

  1. using POST instead of GET,
  2. passing by Cookies
  3. Sending query string to the server by AJAX and adding to the session in the first step and fetching the query string from the session using some GUID concepts.

Here I am going to explain a best and stable solution for all the cases.

Background

We have three situations when we need to pass query string to the web page.

  1. Opening a new window (http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx)
  2. Showing modal dialog (http://msdn.microsoft.com/en-us/library/ms536759(VS.85).aspx)
  3. Showing the URL in iFrame (http://msdn.microsoft.com/en-us/library/ms537627(v=VS.85).aspx)

Request Maximum Size can be configured on IIS Server configuration for Server side.
http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits
[ Thanks : daveauld - http://www.codeproject.com/Members/daveauld  ]

Using the Code

To solve this problem, I have come up with a simple solution using HttpHandler & Javascript.

What is HttpHandler? Read this - http://aspalliance.com/441
How to create an HttpHandler? Read this - http://support.microsoft.com/kb/308001

This solution contains 2 parts, first one is launching/showing the URL using the WindowManager.Js script object, and second part for passing the query string to the web page from HttpHandler.

The below work flow diagram shows internally how it’s working.

How to Implement

Attached sample code contain 2 files, first one is the script file WindowManager.Js, Second one is HttpHandler source code – PageTransfer.CS.

Steps to integrate:

  1. Web.Config Changes.
    Add this entry under system.web\httpHandlers Node.
  2. <add verb="*" path="PageTransfer.axd" 
        type="ApplicationFrameWork.PageTransfer, ApplicationFrameWork"/>
    
         <!— type="ApplicationFrameWork.PageTransfer, AssemblyName"  -->
  3. Add these 2 files in your project folder.
  4. Include the script in your aspx page.
  5. <script src=" WindowManager.js" language="javascript"></script>

Let pass your unlimited query string to your pages.

<html>
<head>
<script src=" WindowManager.js" language="javascript"></script>
</head>
<script language=javascript>
      function OpeniFrame()
{
      WindowManager.LoadFrame("iFrameName", 'WebForm1.aspx', 
          'name=elayaraja&Your=UnlimitedQueryString', 'Your Title')
}

function OpenWindow()
{
      WindowManager.OpenWindow ('WebForm1.aspx', 'Your Title','400px','500px',
          'name=elayaraja&Your=UnlimitedQueryString')
}

function OpenModalWindow()
{
      WindowManager.OpenModalWindow('WebForm1.aspx', 'Your Title','400px','500px',
          'name=elayaraja&Your=UnlimitedQueryString')
}
 
</script>
<body>
    <form id="form1" runat="server">
    <div>
      Open Window <input type=button value="Open" onclick="OpenWindow()" />
      Load Frame Page<input type=button value="Frame" onclick="OpeniFrame()" />
      Open Modal Dialog<input type=button value="Frame" onclick=" OpenModalWindow()" />
 
    </div>

    <iframe id="iFrameName" width="100%" height="300px" frameborder=1>
    </iframe>

    </form>
</body>
</html>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect iSOFT R&D Pvt Ltd
India India
Currently working as Technical Architect at iSOFT R&D Pvt Ltd,Chennai.

Comments and Discussions

 
Questioniis limits too Pin
derekchen10-Dec-12 16:55
derekchen10-Dec-12 16:55 
Generalinteresting Pin
Pranay Rana22-Dec-10 0:04
professionalPranay Rana22-Dec-10 0:04 
GeneralMy vote of 1 Pin
Oakman6-Sep-10 10:09
Oakman6-Sep-10 10:09 
GeneralNot bad, but... Pin
Gregory Gadow1-Sep-10 12:03
Gregory Gadow1-Sep-10 12:03 
GeneralRe: Not bad, but... Pin
Elayaraja Sambasivam1-Sep-10 20:00
Elayaraja Sambasivam1-Sep-10 20:00 
GeneralRe: Not bad, but... Pin
Gregory Gadow2-Sep-10 3:22
Gregory Gadow2-Sep-10 3:22 
GeneralRe: Not bad, but... Pin
Oakman6-Sep-10 10:03
Oakman6-Sep-10 10:03 
GeneralBad Programming PinPopular
Corey Fournier1-Sep-10 8:21
Corey Fournier1-Sep-10 8:21 
GeneralRe: Bad Programming Pin
Munim Abdul1-Sep-10 9:34
Munim Abdul1-Sep-10 9:34 
QuestionRe: Bad Programming Pin
Elayaraja Sambasivam1-Sep-10 20:14
Elayaraja Sambasivam1-Sep-10 20:14 
Hi,

While writing enterprise application in web, it is not possible to keep all the parameters(related to the current user/screen) in the Database as well in the session. Without moving them to the client machine, it will not scale more than 3000 users.

I have the same comment on your statement - immature and unprofessional. I would have felt little happy if you had substantiated your comment with a backup solution. It seems like there is no experience of working in an enterprise application and your comment looks like a comment from first year college student !
QuestionRe: Bad Programming Pin
Elayaraja Sambasivam1-Sep-10 20:15
Elayaraja Sambasivam1-Sep-10 20:15 
AnswerRe: Bad Programming Pin
Eric Xue (brokensnow)3-Sep-10 23:25
Eric Xue (brokensnow)3-Sep-10 23:25 
Generalplease format the article Pin
ThatsAlok31-Aug-10 18:33
ThatsAlok31-Aug-10 18:33 
GeneralLength Limitations Pin
DaveAuld31-Aug-10 7:43
professionalDaveAuld31-Aug-10 7:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.