Click here to Skip to main content
Licence CPOL
First Posted 4 Aug 2011
Views 5,496
Downloads 165
Bookmarked 10 times

Cookieless Sessing Using MVC + Post Enabled Forms

By | 6 Sep 2011 | Article
Cookieless sessing using MVC and post enabled forms.

Introduction 

The code provided allows the programmer to use standard functions in order to maintain POST in forms when using a cookieless session and MVC.

Using the code  

Once the classes are added to your project, it's as simple to use the new functions as before. 

<% 
using (Html.BeginFormNoCookies("Claim")) { %>    
     //Form Contents here
<%} %>

Form ID is the only parameter. It is technically not required, except for when Client Validation is enabled.

How it works

The existing BeginForm is just an extension and that is exactly how I implemented this. In fact, I downloaded the source for Microsoft's MVC2 FormExtension. I changed the function names to not cause any confusion. A new parameter had to be added in order to deal with the fact that I wasn't able to maintain the dynamic form ID creation since some existing methods were internal to System.Web.MVC. The next major part was constructing the URL and always including the session ID as well as any actions, IDs, or query parameters.

I created a class called CookielessHelper. This is what creates the URL. The URL is constructed around the Controller. It is always expected to be in the following format: /{Root Information}/{Controller}/{Anything}?{Query}. The session ID is always added before the controller and everything else is always preserved.

Note

This version as of now does not have Route modifications enabled. If you use any other function than the one listed, the session ID will not be added. All other functions are currently commented out until they can be completely implemented. I am sure it is not difficult, but I don't need it at this point.

History

  • 8/4/11 - Linus Concepcion pointed out that I can get the Controller by way of the HTMLHelper. Thanks! (Removed require parameter View Page.)
  • 8/4/11 - Initial release.

License

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

About the Author

Corey Fournier

Software Developer

United States United States

Member

Graduate of University of Louisiana at Lafayette in computer science.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberchriszwang11:31 29 Sep '11  
GeneralRe: My vote of 5 PinmemberCorey Fournier2:15 11 Apr '12  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 6 Sep 2011
Article Copyright 2011 by Corey Fournier
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid