C# - Session At The Page Level Blocks The Pagemethod Calls?
Feb 24, 2011
The Situation: When there multiple PageMethod calls in a single page, each of the method call holds a lock on the Session object thus blocking. The PageMethod calls can be made asynchronous only with @Page directive is turned to False|ReadOnly
Findings: When the Page directive is default (read/write) but the session is not used anywhere on the page, the calls are not blocked. Any read or write in to the session at the page level blocks the pagemethod calls.
The Problem: Making EnableSessionState=ReadOnly at the @Page directive is very restrictive and don't want to take that route. Can the pagemethod calls not block? and still access the session? (may be not write but just read)
I'm calling a static Page method via javascript that takes between 5s and 10 min. I'd like to give my user the choice to either continue waiting for the request to complete or not, and use window.setTimeout() to check back every 30s.
I've tried both location.href = '/newpage.aspx' or firing a button's click handler (which does similar redirect) to redirect the user prior to completion of the page method, to no avail. I can immediately send user to a simple html page, but a redirect to any aspx page involving server-side appears to block. When the page method finally completes, the redirect does succeed.
Is this:
a browser issue? If all modern browsers support at least 2 concurrent requests per domain, why wouldn't this work?
a framework limitation? a desirable design pattern or even possible? I've checked, and after redirecting to an HTML page, the original request continues processing (db updates, no problem).
I have a site that when a user logs in it sets their initials into a session variable and sets the timeout value like so:
[Code]....
I want the user to be logged in for 3 hours. This does not work, the session expires after a short period of time, maybe 20 minutes. What do I need to change to make this page level validation work?I have tried setting in web.config also, but this doesn't work either.
[System.Web.Services.WebMethod(EnableSession = true)] public static void SetSession(int amount, int item_nr) { HttpContext.Current.Session["amount"] = amount; HttpContext.Current.Session["item_nr"] = item_nr; }
only, it seems that the Session vars are not set. When I try to Response.Write out the Session vars, I get nothing. I get no errors, and I can alert out the values passed from the onclick event, to the js function, so they are there.
I have to handle error related to web application. I am not sure how its works. I am thinking that I will add an error page (error.aspx) and in global.asax ,application_onError, I will redirecting the user to error page and that should be enough ! i mean it will handle error automatically.
This is quite straight forward. I'm calling a web-service (.asmx, with session enabled) from a c# application. I want each call to be with the same session key as the previous one (as opposed to creating a new session key each time).
I'm making an ajax call using jquery to an asp.net mvc controller action:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult GetWeek(string startDay) { var daysOfWeek = CompanyUtility.GetWeek(User.Company.Id, startDay); return Json(daysOfWeek); }
When session times out, this call will fail, as the User object is stored in session. I created a custom authorize attribute in order to check if session was lost and redirect to the login page.
We have an external site which the users in our company connect to by giving their corresponding username and password. The external site is an ASP.NET website. We want to integrate this website into our intranet portal so that the users don't have to enter their UN/Pwd to login to the website. Since the target website has no provision for SSO, we are simulating the POST request to login.We are now required to perform an action after the initial login is done, on an another page. We can simulate the corresponding POST request as well
I've inherited an asp.net web solution, which has business logic and data calls as seperate assemblies. In the business layer there are a small number of calls to get/set HttpContext session values. I've looked around for an example that will allow me to abstract this away from the business logic as I'd like to be able to reuse these assemblies in non-web projects, could anyone please give me an example of the best way to do this. I was thinking of some sort of session factory that will obtain values from some sort of persistant store depending on the usage scenario but I'm new to architecture really and would appreciate a pointer or two.
If I have a 2 control load events and one page load event subs and the control1_Load events fires first, can I lookup some database things and persist them? I would like to use the persisted data in the other two events when they fire. Normally I've been using session variables , is there a better way?
Is it possible to get session cookie name in medium trust level? The code below works in full trust, but throws a security exception in medium trust level.
creating session object to use across my web application.
I'm working on an application that requires a login control upon which we would need to set around 10 different session variables (related to the user). These values are required/ used many times across the web application so it would be really handy to create a class/ object which can be accessed in all pages with doing multiple lookups into the user table on DB. Also, I would like to avoid any conflicts with multiple developers using same session variable names and thereby causing issues down the road.
I know this is not a new kind of request and must have been created and used by many of the developers.
how to implement page level and control level security in MVC applications. Also I would like to know the definition for Page Level and Control Level Security in MVC. Please refer me if any third party tools avilable to implement security in MVC.
The page in which this Page_Load resides is called by a parent page. Each time this Page_Load gets called the value of "file" in the query string will be different. So each time I will be receiving the XML contents from a different file which are inserted into the XmlDataSource and then bound against by the Repeater. Getting the XML data from the file works great but when I bind against the repeater that only works the first time through Page_Load. Each time after that when this code is executed the same results from the first XML file are displayed in the repeater.
What am I missing here. How can I get the XML data to be bound against the repeater on each page load instead of just the first one?
I have a webservice (ASP.NET) deployed on a webfarm. A client application consumes it on daily basis. The problem is that some of its calls are duplicated (with difference of milliseconds). For example I have a function Foo(string a,string b). The client app calls this webmethod as Foo('test1','test2') once but my log shows that it is being called twice or sometimes 3 or 4 times randomly. Is this anything wrong with the webfarm or the code? Note that the webmethod has simple straighfarward insert and update statements.
I have a handler CsvExport.ashx that resides in the root of my web application, the problem is it is called from a javascript include so I can't use ~/ how can i have it so that any call to a file name CsvExport.ashx in in folder in the web application get sent to the proper file?
I want to be able specify to do the following: Specify configuration settings such as appSettings and connectionStrings for multiple web apps in IIS7 No editing Machine.config or the machine-level web.config Web apps are distinct web sites in IIS (not subfolder apps) Is this possible without just duplicating the configs for each app?
I have a method in a dll which fires of call to a wcf service after some processing. The aspx page has to make the dll method call and redirect back or redirect to another page.So I need to call the method asynchronously on the page load and then redirect without waiting. How do i do this??
I have a page that calls on an asmx within the project (for some ajax stuff). Within that asmx I'm calculating a value and returning it to be output to the screen.
However I need to do a recalculation that includes summing this value with a few others. The function that performs the calculation is in a UserControl on the page.
How do I get a reference to the page object so I can use FindControl to get an instance of the user control so I can call that calcuation function?
I have an existing asp.net web application I am redesigning to use a service architecture. I have the beginnings of an WCF service which I am able to call and perform functions with no problems. As far as updating data, it all makes sense. For example, I have a button that says Submit Order, it sends the data to the service, which does the processing.
Here's my concern: If I have an ASP.NET page that shows me a list of orders (View Orders page), and at the top I have a bunch of drop down lists for order types, and other search criteria which is populated by querying different tables from the database (lookup tables, etc). I am hoping to eventually completely decouple the web application from the DB, and use data contracts to pass information between the BLL, the SOA, and the web app. With that said, how can I reduce the # of WCF calls needed to load my "View Orders" page? I would need to make 1 call get the list of orders, and 1 call for each drop down list, etc because those are populated by individual functions in my BLL.
Is it good architecture to create a web service method that returns back a specialized data contract that consists of everything you would need to display a View Orders page, in 1 shot? Something like this pseudocode:
public class ViewOrderPageDTO { public OrderDTO[] Orders { get; set; }[code].....
Or is it better practice in the page_load event to make 5 or 6 or even 15 individual calls to the SOA to get the data needed to load the page? Therefore, bypassing the need for specialized wcf methods or DTO's that conglomerate other DTO?
How do I go about making true ajax requests to an asp.net page? (Not update panels). I read this tutorial but couldn't get it working. Is there a better approach? Or should this work?