Asp.net - Unable To Access Session State From Class?
Jul 2, 2010
I have a Dynamic Data application to which I have added a class for extending EDM. Everything works great, but now I am trying to set an entity property value equal to a value in session state - and its not recognizing the Session command. I'm trying to do something like this:
audit.action_by = CStr(Session("person_name"))
I think this is because I do not have the class Inheriting Page, but if I do add Inherits Page it breaks other stuff. How can I have the class include the ability to utilize sessions directly without inheriting Page?
View 2 Replies
ADVERTISEMENT
Feb 3, 2011
I'm looking for some smart ideas on how to quickly find all usage of session state within an existing asp.net (MVC) application.
The application in question was the subject of outsourced development, and has been running fine in production. But we recently realised that it's using InProc session state rather than (our preferred route) StateServer.
In a small scale test, we switched it over to StateServer, and all worked fine. However, when we deployed to production, we suddenly experienced a large number of errors. I'm not sure if these errors were caused by this change (they were actually complaining about database level problems), but removing the change allowed the application to function once again (this may have just been because it caused a recycle to occur).
So before I try switching it again, I'd like to perform a thorough audit of all objects being placed in the session (I'd previously taken a quick look at a couple of controllers, and they seemed fine). If I had full control over the code, this is the kind of place where I'd just comment out the class (to compile and find the various ways of reaching the session class), then comment out the accessors, hit compile, and visit each error. But I can't do that with built in .NET framework types.
I decided to try using Reflector. I've analyzed the "Used By" for each of the following:
System.Web.HttpSessionStateBase.set_Item(String, Object) : Void
System.Web.SessionState.HttpSessionState.set_Item(String, Object) : Void
System.Web.SessionState.HttpSessionState.set_Item(Int32, Object) : Void
[Code]....
View 2 Replies
Aug 12, 2009
Remembering session state in HttpWebRequest
View 2 Replies
Aug 12, 2009
Remembering session state in HttpWebRequest?
View 2 Replies
Feb 12, 2009
I have several sessions stored at one time, and i want to count a particular one:
i have session.contents("session1") and session.contents("session2")
but i only want to check if there is anything in session2...
I tried this:
If Session.Contents("session2") = "" Then
as in, if theres nothing in it, then do something. But... it says when there is nothing in session2, that theres no object reference, i want to do something like this:
session.contents("session2").count or something
View 1 Replies
Dec 8, 2010
I"m developing a small app in silverligh with VB
I created an :SQL Database , ADO.Net model and a Domin service
The code was auto generated for me.
All im trying to is access the class and call my query.[code]....
View 1 Replies
Jan 18, 2010
I have an uploadify control working fine in a vb.net web application - however whenever I switch on cookieless session state in web.config (cookieless="true") - it stops working. In my upload IHttpHandler I can see that the data stored by uploadify is nothing:
[Code]...
I'm guessing that the flash isn't honoring the session id in my url? how to keep uploadify working when I turn on cookieless session state?
View 1 Replies
Jun 7, 2010
I'm trying to track down a problem on our test environment. Previously it was set to use InProc Session State Type, but I've added in the SQLServer type for one specific Web App. I did this because we use the SQLServer type in our production environment and I want our test env to match as closely as possible.
However, after changing it to SQLServer I do not get any errors when trying to store unserializable data in session like I would expect. It works just fine, even though I would think it shouldn't. I'm a relative newbie when it comes to configuring this, but from the various tutorials I googled, I thought I covered all the bases.I was wondering if there's any code snippets to verify which session state type an application is actively using.
View 1 Replies
Jun 8, 2011
I configured session state in web.config.<sessionState cookieless="AutoDetect" timeout="5" sqlConnectionString="....."/>Now, I want to know timeout and sqlConnectionString from code-behind.
View 1 Replies
Dec 8, 2010
i am still new to using session state, i want to convert page name into and integer according to a database table a function then compares "X" and "Y" to check if a user have the right to view this page..i know this is not the best way of managing website security, but it is like "training on how to use the session".[code]
View 1 Replies
Dec 21, 2011
I have a bit of strange behaviour in an asp.net web application that involves the session state being lost.
Process A user logs into the application and the session is set. They then fill out 1 field, and the application then does an AJAX POST to a .asmx web service. Within the web service, I am using a HttpWebRequest to grab data from another server.
This data is then output to the browser.A few more fields are then filled in, and the data is then again Post to the same web service via an AJAX POST.
[Code]...
View 2 Replies
Mar 1, 2012
I am trying to access appSettings using the following syntax and I have used it before in my many website projects but not in a class library project. In this class library project I cannot even access the AppSettings Keys. Is there any way I could access the AppSettings Key from my class? Is the class library project's app.config or project structure behave in a different way?
[Code]...
I have already added Project Reference to System.Configuration and imported in my class. When I run my code it says, "Object not set to an instance of any object".
View 2 Replies
Nov 11, 2009
I am storing an array of a custom serializable class in session on my site. When a page on the site changes, suddenly it renders them invalid, and tells me that it can't cast the type to it's own type. I assume the class version numbers are changing or something?!
I'm not trying to redesign this whole process.
Unable to cast object of type 'ShipmentPackages[]' to type 'ShipmentPackages[]'.
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'ShipmentPackages[]' to type 'ShipmentPackages[]'.
[Code].....
View 2 Replies
Aug 6, 2010
This is an ASP.NET 2010 web app written in vb. I use several Session variables. I want to pass them all to a central class and let the class manage them. However, I am having some trouble. Here is the code on the calling page:
Dim arrGoodSessions() As String ={"nameofsession1", "nameofsession2", "nameofsession3"}
Utilities.ManageSessionVariables(arrGoodSessions)
It calls that static Utilties class. I have set a reference to System.Web. Here is the code in the class:
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.SessionState.HttpSessionState
Imports System.Web.HttpContext
[code]....
This attempts to simply read in some names of session variables and then cycle through all session variables and remove any I didn't list. This works when all of the cod eis on the page. But when I move this to the class, it doesn't recognize Session.Contents.
View 3 Replies
Feb 2, 2012
I have a class with a subroutine as follows:
Public Sub SetPermissions()
If IsNothing(HttpContext.Current.Session) Then
Exit Sub
Else
[code]....
I know that my session variable is not yet set, hence a null value, that's why i'm trying to handle it with IsNothing, but my code still bugs out on me.
View 1 Replies
Feb 15, 2012
I am using this example I found to learn how to load class files and access variables through them. This is in a file called Class1.vb in the App_Code folder (this is not an app project):
Imports Microsoft.VisualBasic
Public Class my_class
Public Shared Sub my_sub()
[Code]....
How could I access the vartest variable without using a session, since if this is accessed by multiple functions at the same time the variable can be overwritten I assume. Is it possible to go the other way, where a variable is sent to a class file?
View 4 Replies
Aug 29, 2011
How can I access the values stored in a session object with a class in asp.net?
View 3 Replies
Jun 7, 2012
I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?
[Code]...
View 3 Replies
Nov 14, 2009
I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]
View 1 Replies
Aug 22, 2010
When we create an instance of a class we also provide its state so are these both same and if not same what's the difference? And also what's the difference when we use equals method for instance or for state?
View 3 Replies
May 27, 2010
How should class member variables be used in combination with class methods?Let's say I have a class 'C' with a member variable 'someData'.I call C.getData(), which does not return a value but instead puts data in C.someData. The class that instantiated 'C' first calls C.getData and then uses the data by accessing the member variable C.someData.I call C.getData() in the class that instantiated 'C' which is a function that returns data.I myself prefer the second way. But it also depends on the situation and it's a small difference. Is it 'bad' to have class methods that depend on the classes internal state? What are the best conventions?
View 2 Replies
Nov 6, 2009
What is the best way to provide strongly typed access to the session object? I am planning on turning on Option Strict, which is causing the compiler to complain about my lazy programming technique of directly accessing the session object:
Dim blah As Integer = Session("Blah")
My initial thought is to create a class that wraps the session and provides strongly typed properties for the information stored in the session. However, I cannot decide if the class should be a singleton, or instantiated on every use, or where the code should reside (i.e. within the web project or within a class library).
I'm leaning towards a singleton in my class library, but I don't know if that is the best solution, or if I am missing any other possibilities.
Proposed Solution:
Public Class SessionAccess
Public Shared Property Blah(ByVal session As HttpSessionState) As Integer
Get
[Code].....
View 2 Replies
Sep 15, 2011
I'm fiddling with sessions in asp.net in a http module.The problem:
session("whatever") = "something"
is set on page_load I need an event in the http-module which is executed after page_load, and in which I have access to the session in System.Web.HttpContext.Current.Session I was looking at this HTTPModule Event Execution Order? but I can only get the session in PostAcquireRequestState, which obviously comes before page_load...
View 1 Replies
Jan 27, 2011
the following web.config file is placed in a specific sub-folder on a website. It will allow the user John.Doe to access the pages inside the folder but will deny anonymous users
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
[code]....
View 1 Replies
Sep 16, 2009
I am trying to access the checked state of a CheckBox from a BackGroundWorker thread. I am utilizing properties and it seemed to work just fine. However, I'm using 10-15 CheckBoxes and I think using the InvokeRequired property would probably be best. I've looked over JMC's thread that talks about how to access controls from the worker thread a bunch of different times and I can't seem to grasp the concepts. When it comes to the InvokeRequired property, I suppose I understand why it is needed. But I'm not sure if I understand it completely.
From the example that JMC provides:
vb.net
Private Sub ResetTextBoxText()
If Me.TextBox1.InvokeRequired Then
Me.TextBox1.Invoke(New MethodInvoker(AddressOf ResetTextBoxText))
Else
Me.TextBox1.ResetText()
End If
End Sub
If I'm not mistaken, this tells us that if invocation is required to access the control, then we access via the MethodInvoker if not, then we just access to directly? So, if I need to check the checked state of a check box, I know I can just put a conditional statement after the Else line if I can access it directly. But, if I can't how would I use MethodInvoker to check the checked state? And then, when calling it from the worker thread, would I just call the sub?
View 9 Replies
Dec 8, 2011
I am storing a session variable that a user types into a textbox. With their valid input, their session gets created and they get a little more functionality than the regular end users of the site.I was wondering if it is possible to find a way to add someone's session variable to the end of a URL. This way we can email a link to one of our clients, they click it, and their session has automatically begun. They already have the textbox to enter their code into, but I was told that it would be much easier for the users to just click a link that will start their session.
View 1 Replies
May 28, 2009
On startup of my software which i developed in vb.net, it connects to mssql server. I want to have session id or session number of the connection with mssql. I'm sure it is unique number and i want to use this session in my software for different purposes. My question is
1. is there anything like session id or session unique number when you connection mssql server
2. if yes to 1 then how i can get it in vb
View 1 Replies
Jun 11, 2009
I have had several occasions recently to access a specific class several times over a relatively small time frame.So I've been storing the value of the class in Session and trying to access it on page load, if it's not available creating a new instance and storing that in session.
So instead of constantly replicating the same code for different classes on different pages I'm trying to create an extension method to do this for me.
[Code]...
I'm stuck on what to do when I make my new instance of my class (it would have to have a New() sub)
I'm not sure where to go from here... or even if this is the best way to do it.
View 2 Replies
May 25, 2010
I wrote a class and now that i find it works, I need to tweak it, but cannot locate it.
View 4 Replies
Aug 18, 2009
I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.
[Code]...
View 1 Replies