C# - Exchange Session Variables Between Webmethods In Webservices?

Sep 14, 2010

I have the following code to store session variable in one webmethod and retrieve it in other webmethod but the value displays null when i try to retrieve it.

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool SubmitList1(string businessname )
{
Session["Company_Name"] = businessname;
SqlConnection con = new SqlConnection();
.......
.........
.........
}

This will be my second webmethod where i am trying to retrieve the session variable

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool addresslisting()
{
string companyname = (string)Session["Company_Name"];// this particular value is displaying null
......
........
}

View 2 Replies


Similar Messages:

Could Not Load File Or Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Mar 2, 2011

I'm working on a project that accesses the Exchange Server. Before I replaced the project to a server, everything went fine. But now I'm getting this error.

View 2 Replies

Best Practice When Using WebMethods And Session?

May 15, 2010

I want to reduce postback in one of my application page and use ajax instead. I used the WebMethod to do so.. I have a static WebMethod that needs to access the session variables and modify. and on the client side, i am calling this method using jQuery. I tried accessing the session as follows:

[WebMethod]
public static void TestWebMethod()
{

[code]...

The values are displayed correctly and seems to work.. but i would like to know if this practice is allowed as the method is a static methods and would like to know how it will behave if multiple people access the application.I would also like to know how developers do these kind of tasks in ASP if this is not the right method.

View 1 Replies

WCF Vs ASPX Webmethods Vs ASMX Webmethods?

Dec 3, 2010

The intent is to create a set of web services that people can reuse. These services mostly interact with a backend DB creating, retreiving and processing data. We want to expose services so that people can use to create data mashups and other applications.End users are webpages that can be within our domain or outside our domain. For pages outside the domain we plan to release widgets that would be configured to retreive and display the data.

One requirement - application should be extremely scalable in terms of the number of users it can handle.Our code base is .net and we are looking at ASPX webmethods (or ASHX), ASMX webmethods and WCF (starting to read up on WCF). In terms of security/access I found that maintaining sessionid, memberships is doable in all three. WCF seems a bit complicated to setup. I could not immediately see the value of asmx when we can get all done just using a webmethod in aspx (with a little tweaking). Also, assuming that with the ASP.NET MVC2 I might be able to get clean urls as well for these webmethods.QuestionsWhich one will be the most effective in terms of performance and scalability? Any reason why I should choose WCF or ASMX?

EDIT I kind of understand that WCF is the way to go. Just to understand the evolution of the technologies it would be good if someone can throw light on why a aspx webmethod is different from an asmx when similar things (apart from discovery) can be accomplished by both. The aspx webmethods can be made to return data in other formats (plaintext, json). Also, it seems that we can build restful services using ashx.

View 2 Replies

Collect 2 Variables From One Hyperlink, And Use Those Variables In The Page_load To Set As Session?

Aug 8, 2010

i am trying to collect 2 variables from one hyperlink, and use those variables in the page_load to set as session. but i don't know how to collect those 2 variables

such :

<a href="javascript:;" onclick="wsChangeColor('mainData', '#FF0000','#FFE4E1');return false;" title="Change color" id="red">1</a>

i would like to collect '#FF0000','#FFE4E1' or direct set '#FF0000','#FFE4E1' to string then send to pageload, how can i do this by only clicking on it ?

View 1 Replies

State Management :: Session And Session Variables Not Stable In Development Server?

Oct 11, 2010

I use some session variables to get the job done(shopping cart, etc) but it is not stable..manytimes I get no items in session object and other times(refreshing the page) I get missing data...I downloaded the entire site code to my local pc and debugged it and run it succesfully without any session data missing...When I run it in the server, I get bad session again: no products in shopping cart or products with missing quantities...

The same website runs smoothly in our production server too....The problem is with our development server...

View 2 Replies

State Management :: Session Variables And Tabs / Is There A Way To Reset The Session Variable

Nov 11, 2010

I have some code in my page load event where I just want to fire once when the user opens the Browser. The only issue is if you open a new tab with the same website the session variable does not reset. Is there a way to reset the session variable when you open a new tab or do you have to take the whole web browser down for it to clear the session variable.

In Global Page:

[code]....

View 2 Replies

IIS InProc Session Variables Randomly Not Written To Session

Nov 12, 2010

There are reams of info out there about things causing InProc session to drop session objects, but that's not what's happening here. We're missing individual variables within stable InProc session objects, and are not sure whether they're not being written or being lost after a successful write. I've confirmed with WinDBG that the sessions are live and contain some, but not all, of the data written to them.

Guid g = System.Guid.NewGuid();
this.Context.Session.Add(g.ToString(), result.ImageData);
output.Write("<img src="display.aspx?id=" + g.ToString() + "">");

This code is pretty straightforward, and it works flawlessly in Test. In Production, under heavy load, though, it fails ~1% of the time. If Mr Smith visits the site and attempts to display 4 pieces of image data, 2 of them might be saved in his session and two of them be lost. The InProc session object for Mr. Smith exists. The traffic logs show he clicked 4 times, each with a different id param. But there are only 2 guids in his InProc session object, instead of 4. The 2 session objects we did capture do correspond to 2 of the id's shown in the traffic log (his 1st and 3rd clicks.) The traffic logs for his 2nd and 4th clicks, though, show a guid id that's not in his InProc session object.

Lines 1&3 of the above code obviously worked for those 2nd and 4th clicks, or he'd not have had the id in the URI for him to click. Line 2, however seems to have failed silently in some way. If any exception had been thrown, I'd expect we'd not ever have arrived at line 3. I can't see any way for the user to receive the guid id, but the session to fail to have it. The other possibility is line 2 worked successfully, but the variable later disappeared, how I cannot even imagine.

Details:
ASP.NET v3.5
IIS 6
No Web Gardening

We're running a web farm, but users constantly return to the same server. I'm researching now whether there's any way users might be slipping off to the other server.

View 2 Replies

Where Are The Session Variables Saved

Dec 24, 2010

Where exactly are session variables saved? Cookies? Server memory? Again where are Application variables saved?

View 3 Replies

How To Clear The Session Variables

Mar 22, 2010

I need to clear all sessions at the end of my application, to many to list individually.

So I have found the following ways, but which is best?

Session.Clear();
Session.Abandon();
Session.RemoveAll();

And then the specific way

Session.Remove("variable");

View 5 Replies

How To Set Cookies And Session Variables

Jan 27, 2010

Am trying to design login page for my website and I am looking for methods other than forms authentication. The way in which I am trying is to have a table in the database that stores user information and check for the user validity.

The point where I get struck is how do i set cookies and session variables and how will I carry it through out the system. Can anyone tell/suggest me where I can relevant material so as to move forward. And also is my idea of negating traditional forms authentication and going for a model I described, is it good also does any other better method exist?

View 1 Replies

MVC :: Session Variables For Authentication?

Jul 30, 2010

I want to password protect an area of a website by a login/registration form.

I'm using session variables to check wheter the user is logged in or not. I already have a database with users/passwords... so I thought that the membership approach wasn't an option... (correct me if I'm wrong)

in the constructor of the controller of the area I want to protect I've added the following:

[Code]....

but this throws an error:

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. review the stack trace or 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:

[Code]....

Line 28: this.productsRepository = productsRepository;Line 29: Line 30: if (Session["user"] == null)Line 31: RedirectToAction("List", "Products");Line 32: }

View 2 Replies

MVC :: Accessing Session Variables

Nov 10, 2010

I am working on an asp.net mvc app.Right now I am looking for the best solution to access session variables.
Is it oke to make a static class to get session variables, like:

[Code]....

And so on for other session variables.Is it allowed to access session variables in static model classes ?

View 2 Replies

Manage One's Session Variables?

Mar 25, 2010

In my .NET web app, I keep basic user info in a user session object. I also usually keep a director class in the session; which is basically just has info about whatever thing it being worked on on that screen (like a customer id).

I am trying to keep from adding a ton of sessions. I also want to make sure at any given time ONLY the sessions that are necessary are in memory.

This means I need an effective way of managing my session variables.

View 6 Replies

Are Session Variables Case-sensitive

Mar 28, 2011

I am using ASP.NET 2.0 and C#. I would like to know if the Session variables are Case-sensitive.

Is Session["StudentId"] and Session["StudentID"] considered the same.

Which would be the proper way to access the session details, when in a page someone passes data as Session["StudentId"] and somebody else passes as Session["StudentID"]?

View 6 Replies

VS 2008 - Using Session Variables Get Corrupted

Jun 10, 2010

I have a situation where my session variables seem to get corrupted. I Page_Load I am calling 2 subs. Each of them fills a GridView with data from a table. I am saving the content of each Data.DataTable into Session Variables:

Get_Summary_Last_Completed_Shift()
code in sub:
mySqlDataAdapter.Fill(mySqlDataTable)
Session("mySqlDataTable1") = mySqlDataTable
GridView1.DataSource = mySqlDataTable
GridView1.DataBind()

Code:
Get_Petroleum_Disbursement()
code in sub:
mySqlDataAdapter.Fill(mySqlDataTable)
Session("mySqlDataTable5") = mySqlDataTable
GridView5.DataSource = mySqlDataTable
GridView5.DataBind()

After I call the 1st sub and I debug the session variable "mySqlDataTable1" contains all the data from the table. After I call the 2nd sub and I debug the session variable "mySqlDataTable1" has been changed and contains a mix of data from the 2 tables.

View 2 Replies

Session.State And Passing Variables?

Oct 15, 2010

I'm trying to pass some variables from one page to another via the session state and then post those variables to labels on page 2. When I try to write the code for my labels on page2, I get an error of "Declaration expected"Here is my code from that page:


Partial Class Default2
Inherits System.Web.UI.Page
Dim firstname As String = CType(Session.Item("FirstName"), String)
[code]...

Am I missing a page_load event handler or what am I missing?

View 2 Replies

Implementing Security With Session Variables?

May 5, 2010

I am doing web based projects in dotnet. Currently I am implementing security using session variables. I keep current user id and user type in session and authenticate user from these session variables (say Session["UserId"],Session["UserName"] and Session["UserType"]).

I've heard that such security can be broken and applications can be hacked very easily, like it is possible to get session id and directly connect to that session id etc.

View 1 Replies

Preserve Session Variables Across HttpHandlers?

Aug 19, 2010

I have an ASP.NET application with 5 .ashx HTTPHandlers that implement RequiresSessionState or IReadOnlySessionState.Upon calling the first handler I create a variable and store it in the session.When I call the next HttpHandler the variable is not available in the session object.I am use context.Session.I have a global.asax where I retrieve the sessionId.Is there a way to preserve session variables across HttpHandlers or does each Handler get its own session?

View 1 Replies

Session Variables Inside Of SharePoint?

Oct 26, 2010

I am having with asp.net app inside of SharePoint (as page viewer).

When the Default page is loaded, it works fine. However, when I try to go to next page, i am getting a null reference exception. It looks like my session variables are becoming null on the next page (even though I set them on the previous page). Here are a couple things that I tried to diagnose the problem.

I try on the couple other computers; some work fine, some still don'ts. In the property of the page viewer inside of the SharePoint, after I click on the "Test link", it started to work fine until the session expired (on the computer didn't work initially).

I am not sure if there are settings that I need to check on the browser or the app server.

View 1 Replies

Loading Cycle And Session Variables?

Jan 26, 2010

I am setting a session variable when the user selects a value from a dropdownlist (SelectedIndexChanged) in webusercontrol #1.

The page then refreshes and I thought that webusercontrol #2 on the page should be able to access the session variable in its page load.

However the session variable is not available until the user refreshes the page again. I'm assuming that the page is refreshed before the session variable is updated.

View 1 Replies

C# - Use Session Variables In Windows Application Using VC#?

Feb 24, 2010

im new to asp.net. . . im doing my final year project.How to use session variables in application using VC# and I also need to check with data base?

View 2 Replies

Session - Saving Variables In Page?

Dec 25, 2010

I'm trying to convert a game I made (WindowsFormApplication) to an ASP.NET page.

My Problem is that I have a lot "private" variables in my WindowFormApplication and those variables are important for the game. But when after I Declare all my variables (in my Page_Load), they turn null no matter what I do(click a button, refresh the page).

Is there anyway to save my variables between buttons (other than Session, because I'd have to create like 6 more sessions)

View 1 Replies

Save Image Into Session Variables

Aug 22, 2011

I would like to know how to:

- Save an image into a Session Variables
- Get the image from the Session Variable and display it on the web page.

Here's the example on how to get the image from the DB:

string v_customer_code = "PAUL";
SqlConnection v_connection = newSqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString))
v_connection_string = "SELECT [Photo] FROM [customers] WHERE [code] = @CODE";
SqlCommand cmd = new SqlCommand(SQL, v_connection);
cmd.Parameters.AddWithValue("@CODE", v_customer_code);

[code]...

View 3 Replies

Session Variables Are Dropping Within 2 Minutes

Aug 2, 2012

I am currently working on an ASP.NET v4.0 project using VB Script for the server-side code. I have a number of session variables that I am using across multiple pages. My problem is that although I have set the session timeout to be 20 minutes or longer (programmatically, in Web.Config, and IIS), the Session variables are being dumped after exactly 2 minutes.

Web.config contents:

Code:

Session_Start routine:

Code:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session.Timeout = 1200 ' Setting to a very high number to ensure that whatever timeout value is set in IIS *should* stick
Session("VariableNames") = VariableValues ' ... multiple values here
End Sub

After exactly 2 minutes (120 seconds) from the last refresh, all the values retrieved using Session("") are blank. Here are a few screen caps to show the IIS settings.

Additionally because of this problem, I have created a generic dummy handle page called KeepSessionAlive.ashx and the following javascript is called using setInterval(KeepSessionAlive, 10000); (every 10 seconds) and I have confirmed that it is working, but the Session variables are still being dumped.

Code:
function KeepSessionAlive() {
//alert('testing');
$.post("KeepSessionAlive.ashx", null, function () {
$("#result").append("
Session is alive
");
});
}

Am I missing something? Why is it dropping my Session values?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved