.net - Session-in-view And TransactionScope?

Dec 21, 2010

we have a asp.net webforms app using NHibernate. Here are some specifics:We need Distributed Transactions because we write to the database as well as to a queue.Because this is a web app, we use the recomended Session-in-view pattern. We have a HTTPModule that opens the NHibernate session on the BeginRequest event and closes it on EndRequest.Within the flow of a request, we have several separate moments where we need to do transactional work. For this, we use TransactionScope.So basically, what happens is this (pseudocode):

using(var session = sessionFactory.CreateSession()){
using(var tx1 = new TransactionScope(){
//work work work

[code]...

View 2 Replies


Similar Messages:

ADO.NET :: Using TransactionScope In BLL With TableAdapters As DAL?

Dec 26, 2010

I have two BLL classes ItemsBLL & BalanceBLL. When ever a new Items gets Added to Items table few details needs to be added to Balance Table.

I am using the following code to perform the operation, is this code efficient or something needs to be changed.

The function that needs to be checked is the Insert function in ItemsBLL Class.

[Code]....

Is this function effective?

[Code]....

[Code]....

View 11 Replies

ADO.NET :: LINQ And TransactionScope?

Mar 4, 2011

I have a requirement whereby I either have to perform and update or an insert on 1 table inside a transactionscope

There are 3 table in total, 2 will always be an insert, but 1 could be either an update or insert depending if some data already exists a foreign key relationship exists between all 3 tables (not on the same column though)

heres my code

[Code]....

[Code]....

View 2 Replies

TransactionScope In A Medium Trust

Feb 3, 2010

Im running an ASP.NET MVC application hosted with Mosso, there are telling me that they cannot enable DTC because they run everything in medium trust.So when executing code that references: TransactionScope I get the following error. The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)

Is there anyway to get around this?

View 1 Replies

ADO.NET :: TransactionScope And Explicit Transaction In It

Feb 23, 2011

[Code]....

Now,

1. If In transaction scope if 1st Transaction is commited, buting 2nd one exception occurs and it is rolled back

2. Any other exception occurs, after 1st transaction is completed/commited

Here, explicit transactions are used. In both cases does all transactions in the scope are revert back? What are the possiblities here?

View 7 Replies

ADO.NET :: How To Insert Data In Both Tables Using TransactionScope

Sep 4, 2010

I am working on Sales application. In database i have SalesOrderHeader & SalesOrderDetail tables. They are almost typical Adventureworks db tables.

How to insert data in both tables using TransactionScope so if any of the record from the two tables generate error complete transaction roll-back.

One thing more I am using TableAdapters, My initial concept was inserting record in SalesOrderHeader, get SalesOrderId using Scope_Identity & bulkInsert Records to SalesOrderDetail using TransactionScope.

View 1 Replies

Architecture :: Sending Mail With Smtp Within TransactionScope?

Apr 29, 2010

I have code that is supposed to do some database operations and then send an email through local iis smtp virtual server. All within one TransactionScope. It looks like

[Code]....

The second one where I use something similiar is

[Code]....

I want to notice that these events fire in the sequence they are shown. Now when there's an error, the db operations are rolled back, but the mail is sent anyway. I'm using Windows XP SP3, IIS 5.1, .Net 3.5, Visual Studio 2008. If I'm correct, TransactionScope uses MSDTC, right? I couldn't find anything about MSDTC working with smtp. Should it even work?

[code]....

View 2 Replies

Can TransactionScope Rollback A Transaction After The Connection Is Closed

Jul 24, 2010

Suppose say I am doing a couple of operations.

First a delete and then an insert.

Now, these two operations are done with two different connections (say con1 and con2). Both these connections are enlisted in the same TransactionScope.

Before the delete/insert operations the connections are opened and immediately closed.

So, now if the insert fails, then how is the delete rollbacked since con1 has been closed?

View 1 Replies

Will Transactionscope Work Over Multiple Calls To Different Services

Jun 18, 2010

I'm writing some merge functionality in C# asp.NET MVC2. I am also using using Linq2SQL.

I have a block of code which calls two services, MessageService and UserService. These both in term call their appropriate repositories and make the amendments to the db. Each repository declares it's own instance of the repository so I'm thinking this will escalate the following code to DTC . The code is called from the AccountService, is this going to work at this level? And also is it bad practise to declare the DataContext at the top of every repository or should I pass the object around somehow?
//Run the merge
try
{
using (TransactionScope scope = new TransactionScope()) [code]....

View 2 Replies

ADO.NET :: After Domain Changed TransactionScope Acting Wierd?

Feb 18, 2011

I m using transactionscope and there was no problem until my domain changed.When it hits the scope7, it inserts the data and starts all over again and inserts for the second time.

Here is my sample code:

Using scope7 = New TransactionScope(TransactionScopeOption.RequiresNew)
Dim comm As New Data.SqlClient.SqlCommand("INSERT INTO ABC (ID, AID, Type) VALUES (@ID, @AID, @Type)", conn)
comm.Parameters.AddWithValue("@ID", TaskID)
comm.Parameters.AddWithValue("@AID", FormID)
comm.Parameters.AddWithValue("@Type", FormType)
conn.Open()
comm.ExecuteNonQuery()
scope7.Complete()

View 1 Replies

DataSource Controls :: How To Wrap The DataContext's SubmitChanges Within A TransactionScope When Modifying Multiple Tables

Feb 20, 2010

I am confused about why I would need to wrap the DataContext's SubmitChanges within a transactionScope when modifying multiple tables. I was under the impression that the DataContext would track these changes and would therefore create its own transaction if need be.

In other words, if a change was made to update table A, B and C or if I made changes to 10 out of 20 items in a collection of rows, that the datacontext would track these changes and create its own transaction. If that is correct then why have I seen examples that wrapped these types of updates in a TransactionScope?

View 4 Replies

Is It Possible To Place View State In The Session

Feb 15, 2011

(I have a feeling i'm making a mental error thinking this is possible, because it seems too easy, but here goes)

For my intranet web app with 20 users on slow machines, the view state is slowing down their browsers.

But the network is local and fast. So I think to myself, why bother putting all that data on the user's browser?...Something like putting it in the database and then all the page needs to maintain is a unique key. But then I remembered that's how session state pretty much works.

QUESTION: Am I missing something or is this really possible?

View 2 Replies

Which One Is More Costilier View State Or Session

May 21, 2010

Which one more costilier View State or Session when a bulk data is stored. Why?

View 2 Replies

MVC :: Clear Session Object In The View?

Mar 5, 2010

have been a great resource for me since i am new to MVC and trying to learn and figure out few things.My chain of thoughts still might be asp.net, so here is another question.I have a session object in my controller action which i use to populate my view , i need to clear the session object everytime i navigate out of the page (more like a session kill in page unload event). I really appreciate any ideas and inputs on how and where to clear the session object

View 8 Replies

Using Session Variable In Form View?

Mar 3, 2011

I am trying to use this query in a form view "Select * from actions where emp_id = " & session("emp_id") for the select command. This is the format I am used to in classic asp. How can I acheive the same results in asp.net.

View 2 Replies

Using Nhibernate In An Open Session Per View Approach?

Nov 28, 2010

I am using nhibernate in an open session per view approach where the session opens before the action method and closes right after. Using an AsyncController makes this model break because the controller performs data operations even when it has returned from the original XXXAsync method but it finds a null session while the HttpContext.Current is null as well. Is there any way to fix this issue?

View 1 Replies

Requirement Of Session Object View State - Application Domain?

May 17, 2010

actually i got confused in session object,view state,application domain, can u tell me where i have to use these object. can u define some sort of condition in which session object must used & view state must used & diffrence of thses object where we can only use session & where i we can only use view state

View 2 Replies

How To View Session Variables In Visual Studio 2008 Debugger

Mar 30, 2010

Usually using Visual Studio's debugger is a breeze. Scanning through Locals quickly shows the values of variables, etc. However, I'm at a loss how to find out the values contained in session state variables? Can anyone give me a hand?Lets say I put a breakpoint right after:

Session("first_name") = "Rob Roy"

How do I view the value contained in Session("first_name") from locals?

View 2 Replies

Forms Data Controls :: Using Session Variable In Form View?

Mar 3, 2011

I am trying to use this query in a form view "Select * from actions where emp_id = " & session("emp_id") for the select command. This is the format I am used to in classic asp. How can I acheive the same results in asp.net.

View 2 Replies

JQuery :: Grab A Global Variable Or Session Or View State Variable In The Javascript?

Dec 9, 2010

can we grab a global variable or Session or View State variable in the javascript or using jquery?

View 2 Replies

State Management :: Global.asax To Load Up Several Session Variable When A Session Starts?

Sep 14, 2010

I added the following code to global.asax to load up several session variable when a session starts. I'm assuming that when a page goes to use the variable that I should be

1) checking at the page level that the value is valid not 0 when its not expected to be 0, not a zero-length string when its expected to have a length

2) have code at the page level that sets the values if the values have not been set as when the Session timeout, ideally putting the code in a class derived from Page and then deriving all of my pages from the new class so that the code does not have to be repeated in every page

[Code]....

View 7 Replies

State Management :: Differentiate Between New Session Create For New Website Visit Or Session Expired

Mar 2, 2011

I have a problem by getting session which created for new site visit or session expired.

View 3 Replies

Web Forms :: Reset Session If Click Anywhere On Page And Show Popup Before Closing Session?

Feb 25, 2016

I want the code for showing popup dialog box , to show the time remaining for session closing because of in-activity. and 2 buttons for allowing to stay or to signout.

i want all the settings that are need to achieve the  functionality.

View 1 Replies

C# - Store Class Properties In Session And Use Of Session Handler - Is It Good Design

Jul 27, 2010

I have a class called EditMapUtilities. Here are some class properties that I want to persist:

public class EditMapUtlities
{
public static Boolean isInitialEditMapPageLoad
{
get { return SessionHandler.isInitialEditMapPageLoad; }
set { SessionHandler.isInitialEditMapPageLoad = value; }
}
// REST OF CLASS NOT GERMAIN TO DISCUSSION AND OMITTED
}

Here is my SessionHandler Class following the pattern from this post Static Session Class and Multiple Users:
using System.Web.SessionState;

public static class SessionHandler
{
private static HttpSessionState currentSession
{
get
{
if (HttpContext.Current.Session == null)
throw new Exception("Session is not available in the current context.");
else
return HttpContext.Current.Session;
}
}
//A boolean type session variable
private static string _isInitialEditMapPageLoad = "EditMapInitialPageLoad";
public static bool isInitialEditMapPageLoad
{
get
{
if (currentSession[_isInitialEditMapPageLoad] == null)
return true;
else
return (Boolean)currentSession[_isInitialEditMapPageLoad];
}
set
{
currentSession[_isInitialEditMapPageLoad] = value;
}
}
}

I am still learning OOAD. I want to keep relevant properties with relevant classes. I also want to keep all Session stored variables in one place for ease of maintenance and to encapsulate the session keys and calls. I feel like my design is too coupled though. How can I make it more loosely coupled? Is my editMapUtilities class too tightly coupled to the SessionHandler class? How would you do it better?

View 2 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







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