Access The User Session From A Web Method?

Oct 29, 2010

I want to access the user session from a web method. But when I check for the session object, its nothing! How can I access the current user's session from the webmethod?

My code:

<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _.......

View 2 Replies


Similar Messages:

.net - Technique Of ASP.NET Session Access Multi-user Is Safe?

Mar 9, 2010

I am looking at a design pattern which has come up in quite a few of my firm's projects.It has historically functioned correctly, however I have heard some other developers argue that there is a possibility of session corruption using this pattern. I'm looking for insight from other .NET developers here on Stack Overflow. Basically, there's a class -- usually either static or a Singleton pattern, depending largely on the developer who wrote it -- stored in App_Code.This class encapsulates access to the current session via properties.All of these properties take the form of:

[code]...

However,because this is just a static entry to HttpContext.Current.Session,it seems like it should be safe, as it is not fundamentally any different than the Page class encapsulating this in the Session property.As I said,no other site on which my company has worked that used this pattern saw it ever have any issues -- and that includes some pretty large and highly active userbases.But I want to just get a fresh perspective.
Are there potential multi-user issues, race conditions, or other failings/flaws which specifically could cause session corruption in the above pattern?

View 2 Replies

State Management :: Access User Details Throughout Website Using Session?

Jul 28, 2010

when we accept user details in a login page and i want to use login details throughout the website.....can we do like this

session["uname"]=username;

string s=session["uname"].tostring(); this is in first page

string str=session["uname"].tostring(); this is my second web page

it is giving error

we can't access in other pages

View 5 Replies

C# - Access Master Page Public Method From User Control/class/page

Oct 25, 2010

I am to access a method on my master page. I have an error label which I want to update based on error messages I get from my site.

public string ErrorText
{
get { return this.infoLabel.Text; }
set { this.infoLabel.Text = value; }
}

How can I access this from my user control or classes that I set up?

View 3 Replies

Latest Logon Session Is Retained And The User Is Automatically Signed Out From The Other Session

Feb 1, 2011

Let suppose, I am building an asp.net website which has login scenario in it. I want to provide a certain functionality to the website that if the user is already login on computer 1 and now try to login on computer 2, so he will be allowed to remain login on computer 2, while automatically logout him from computer 1. I also know that http is a stateless medium, so whenever user interact with computer 1 and try to interact with the page, it will get noticed at that time.

View 2 Replies

State Management :: Session - User Closes Browser, The Session Does Not Get Killed?

Jul 15, 2010

I have a website live in asp.net

now if user closes browser. the session does not get killed.

I spoke with friend and he said that cannot be done as sessions are on server.

but i see banking website who kills session when browser is closed.

View 10 Replies

Method Is Only Supported If The User Name Parameter Matches The User Name In The Current Windows Identity?

Jan 30, 2011

get the below error. My application was working fine until I probably modified something, but don't know what.

Server Error in '/' Application.

Method is only supported if the user name parameter matches the user name in the current Windows Identity.

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.Configuration.Provider.ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.

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:

[ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.]
System.Web.Security.WindowsTokenRoleProvider.GetCurrentWindowsIdentityAndCheckName(String userName) +2195661
System.Web.Security.WindowsTokenRoleProvider.GetCurrentTokenAndCheckName(String userName) +36
System.Web.Security.WindowsTokenRoleProvider.GetRolesForUser(String username) +61
System.Web.Security.RolePrincipal.IsInRole(String role) +182....

View 1 Replies

C# - Which Session Method To Use When Removing?

Jul 16, 2010

I been using Session.clear() and I noticed in firecookie that the session still exists. So I started to google around and found there are 4 ways to remove a session

Session.Remove(strSessionName); Remove an Item from Session State Collection
Session.RemoveAll() Remove all items from session collection
Session.Clear() Remove all items from session collection Note: There is no difference between Clear and RemoveAll. RemoveAll() calls Clear(), internally.
Session.Abandon() Cancels the Current Session

Now clear and remove seem to do the same thing but which one should you be using like why use remove() over abandon over clear.

Like if you use session.Abandon it kills the current session. Where clear() removes the values.

Why would you only want to keep the session around with no values in it? Why not just kill it completely?

View 1 Replies

User Controls :: How To Call Web Method In User Controller

Aug 18, 2015

I have a web method which is work fine on other page but when I add it user controller it can’t call that method I will debug it means add break point but can’t call.My control are in a folder name User Control...Following my method to call the web method.

url: "UserControl/control.ascx/Savedata",

user control is folder name  and the control.ascx is my control page name and save data are my web method.

View 1 Replies

Access :: Access/SQL Selectcommand And Session?

Nov 22, 2010

I have the following two pages. One is a search page that have a few listbox/textbox/and dropdownlist. The other will be the result page that take from session those 3 data and using an if/else statement to sort out some detail. After that it will form an access/sql selectcommand to search the database base on that 3 criteria. But for some weird reason only the first part of my if and else statement work. Can anyone check and help me out why the rest of the if/else doesn't work. Or point me to another direction?


---------------------Search.aspx-----------------------------

[Code]....

-------------------SearchResult.aspx-----------------------
[Code]....

[Code]....

View 3 Replies

Security :: .net Session And Remember Authentication Method?

Dec 18, 2010

I'm currently developing a website using .net MVC 3 and I'm on the authentication layer...Here is the scenario: user is logged with the "remember me" option checked : a user Session is created on the server as well as the authentication cookie on the client side.The Session timeout is set to 20 minutes.After 25 minutes of inactivity the user goes back onto the website and Session, now expired, does not exist anymore but the authentication cookie still exists

View 1 Replies

User Controls :: How To Insert Time Of Session End When User Closes The Browser

Jan 14, 2014

I have written a SP which maintains users log in and log out history,it works fine when any user logs in or clicks on log out, problem is that as per need its not to allowed  to keep the screen idle for 1 minute or more then in the log out column Null value is passed.

SP

Create proc usp_trackuserlogindetails
@username varchar(50) = null,
@command int = 0
as
BEGIN
if(@command = 0)
begin
insert into userlog (USERNAME,LOGIN,LOGOUT) values (@username,Getdate(),Null)

[Code] ....

Here when user manually clicks the log out button then 1(table above) is the output.

When user leaves the screen idle then after 1 minute the page goes to the Login.aspx page if the user tries to do something on the current page,here 2(table above) is the output can i store some hard core value instead of Null like Session expire or the exact session expires time.

View 1 Replies

Perform User Management (store User Info, Login , Logout Etc) Without Using Session Or Cookie?

Dec 1, 2010

Is it possible to perform user management (store user info, login , logout etc) without using session or cookie?

View 3 Replies

User Controls :: Automatically Reset User Session Without Showing Any Message When Using Master Page

May 7, 2015

URL.... Still there will be need of url in ajax method if i put javascript in site.master.cs . As what i have understood from  that mysite.master.cs will be like this :

protected void Page_Load(object sender, EventArgs e) {
try {
if (Session["Prefix"].ToString().Trim() == "sys_admin") {
UserNameMasterLabel.Text = Session["UserName"].ToString().Trim() + " (ADMIN)";

[code]....

And site.master will be like this :

And I have to put next method in DailyLog.aspx page ? like this

System.Web.Services.WebMethod(EnableSession = true)]
public static int RefreshSession() {
HttpContext.Current.Session["Name"] = "BSD";
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
return timeout;
}

But I have several pages in my website , by doing the above story will it work for Builder.aspx ? or any other page rather than dailylog.aspx ?

View 1 Replies

User Controls :: Check Whether User Is Valid And Authenticated Without Using Session?

Feb 17, 2014

How to Check whether user is valid and authenticated without using Session in ASP.Net ....

View 1 Replies

C# - Response.end Method Causing Session Variable To Expire?

Mar 1, 2011

I am storing the returned sql resultant rows in a session variable ... so that I need not to query again and again

Session["ds"] = datasetname;

Everything is fine but when I am doing export to excel ... where at last after the export is completed I am calling the method in try/catch

try {
Response.End()
}
catch {}

But due to this, my session variable (ds) is getting expired and when I am using it next there is no rows and hence my page displays no data.

I tried going through internet and found that this is a bug it seems as identified by Microsoft and they have provided a hotfix for this but in Windows Vista .... I am running on XP.

[URL]

Is there any other workaround to this problem?

View 1 Replies

C# - Sessions And Sqlsyntax - How To Add A Session To A Login Authenticate Method

Mar 21, 2011

im trying to set up a session for UserID which is contained in the User table along with username and password. Im unsure how to get the UserID based on the username and password in my sqlsyntax then pass it to my session? My last peace of code is just a test in a label to see if it will pass the number to the label.

[code]....

View 1 Replies

ADO.NET :: What Is Best Data Access Method

Oct 3, 2010

I am going to making asp.net 4.0 for first time. I was making my all application in asp.net 2.0 where I was using DAL and BLL method. In that DAL I was making Table Adapter.

Now I am going to make application in asp.net 4.0 and I am thing that my application will become more complex and huge data. Can somebody guide me about stable and fast method for data manipulate like insert, update, and delete also complex query.

View 6 Replies

State Management :: Destroying A Session Of A User From Another User

Apr 23, 2010

I am a little bit new at handling multiple sessions congruently.

Basically i have created a chat application. In which i have a moderator page.

Now the moderator has the privilege to block particular users from the chat. Every user including the moderator has a session variable defined as Session["UserID"].

e.g for the username "moderator" the Session["UserID"]=moderator.

Now as i am logged in as the moderator how do i delete the session of a particular user whom i want to block the chat from commencing.

View 3 Replies

User Controls :: Session Should Not Expire Until User Logs Out

Apr 23, 2014

how to maintain the session that doesn't expire unless and until user logout. 

View 1 Replies

User Controls :: Automatically Log Out User When Session Ends

Mar 3, 2014

How to automatically log out after 15 mins by using asp.net vb.net ....

View 1 Replies

Web Forms :: Save Value In Session - Call Method On Global.asax

Aug 18, 2010

I have a method in one class file with defination like this which gets the user id of logged person.

public string GetUserID(HttpRequest req)
{ .... }

I need to call this method in global.asax and save that value in session. I need to use this session value i need to use this Session value and assign that to label in Masterpage. I did not use global.asax before. And what should be the input to method... i have seen only Request is have the returntype HttpRequest. So i thought of giving that.

View 1 Replies

MVC :: Use Session / Line In Global.asax In Application_Start() Method File?

Apr 8, 2010

I'm trying to use SESSION in my MVC application.I wrote following line in Global.asax in Application_Start() method file:

protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
//uzupełnij zmienne sesyjne
HttpContext.Current.Session["LOCATION_ID"] = 15;
RegisterRoutes(RouteTable.Routes);
}
I also enabled SessionState in Web.config by addind following line:
<sessionState mode="InProc" cookieless="false" timeout="120" />

And when I run the application I'm getting this exception:

Szczegły wyjątku: System.NullReferenceException: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.

Błąd źrdła:

[Code]....

Wiersz 31: //uzupełnij zmienne sesyjneWiersz 32: Wiersz 33: HttpContext.Current.Session["LOCATION_ID"] = 15;Wiersz 34: Wiersz 35: RegisterRoutes(RouteTable.Routes);

View 5 Replies

Security :: Restricted Method Access In WCF?

Jul 12, 2010

I have a WCF service and there are four methods in it. I want to allow 2 methods to client 1 and the other 2 methods to client 2.

View 2 Replies

C# - How To Access Method In Class Library

Jul 23, 2010

I've moved a class in my project into a class Library in the same solution. I've added a reference in the web project to the class library.

How do I access the methods in the class library?

View 2 Replies







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