How To Access Session Values From Layers Beneath The Web Application Layer
Apr 23, 2010
We have many instances in our application where we would like to be able to access things like the currently logged in user id in our business domain and data access layer. On log we push this information to the session, so all of our front end code has access to it fairly easily of course. However, we are having huge issues getting at the data in lower layers of our application. We just can't seem to find a way to store a value in the business domain that has global scope just for the user (static classes and properties are of course shared by the application domain, which means all users in the session share just one copy of the object). We have considered passing in the session to our business classes, but then our domain is very tightly coupled to our web application. We want to keep the prospect of a winforms version of the application possible going forward.
In my application, I'm binding a Collection of Supervisor type, which I'm feeling that it is an additional overhead. Becuase I only want his ID. So binding an object collection to the dropdown which seems no worth.
I have to pass the session value to a business logic layer, I can pass it to the function from presentation layer but how can I access it directly in my business logic layer ? Also is it a good approach to pass it directly to business logic layer like
I was looking to build a Data Access Layer for my new web based application, I'm using ASP.NET. I'm want to build a framework not only for this application but also want to utilize it for my future projects.
Actually my main aim is to make a framework, from DAC, DAL, BL to GUI. I want suggestions from you guys that what should i adopt, what give me flexibility, which suits for both small and large size applications.
I am making use of 3-Tier architecture while making my project. And in Data Access Layer I am making use of application block, but application gets a connection string from web.config; but ClassLibrary of Data Access Layer doesn't contain web config file. How can I access connection string from Data Access layer?
I'm attempting to create Data Access Layer for my web application. Currently, all datatables are stored in the session. When I am finished the DAL will populate and return datatables. Is it a good idea to store the returned datatables in the session?
Note: generally the number of rows in the datatable will be small < 2000.
I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.
For Example
I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.
I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:
public ProductBLL { public int GetProductName(string productId) { ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId); [code]...
Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?
here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.
how the WCF, DAO and DTO layers communicate with each other? I would appreciate if someone can specify which layer comes first and then how it interacts with the next layer
While designing (and then implementing) a layered application:
Is it correct to use the same ORM objects accross all layers? (which would go against encapsulation).
Or the presentation, business and data layer should each have their own objects? (which would lead to lots of code repetition).
e.g. (just to illustrate the question): if one uses Linq to SQL in the Data Layer and Visual Studio's O/R designer to generate the ORM objects, are those objects supposed to be used in the Business and Presentation Layers as well.
i.e.: Are the objects associated with the entities that the application handles a crosscutting issue?
I'm trying to create my first Asp.Net application from scratch. Tried to create this post in some of the other forums but I couldn't find a better place.
So, as the title says, I'm having trouble trying to model my application. I'm like an OOP newbie. I'll show my classes first and then I'll write my questions.
Model Layer
public class User { private int id; public int Id { get { return id; } set { id = value; } } private string login; public string Login { get { return login; } set { login = value; } } private string password; public string Password { get { return password; } set { password = value; } } } Data Access Layer public class BasicDAL { private SqlConnection connection; //>>Returns a new connection to the database public SqlConnection GetConnection() { //>>If connection is active close it before starting a new one if (connection != null) if (connecion.State != ConnectionState.Closed) connection.Close(); connection = new SqlConnection("MyConnectionStringHere"); return connection; } } public class UserDAL : BasicDAL { //>>Insert a new user public void Insert(User user); { /* Insert into DB */ } //>>Authenticate user login with its password public void Authenticate(User user); { /* Authentication code here */ } } Business Logic Layer
[Code]....
So, model layer is pretty simple. Just a user representation. On the Data Access Layer I have a basic class with a GetConnection method. All DAL classes will extend this one.
My first problem lies on Business Logic Layer. With the above scenario, I've placed the same methods that I placed at the DAL. BLL methods would call DAL. As simple as that but I believe It is not the best way to do it, is it? How can I improve those classes?
Also, I have to "try..catch" blocks. That's because I can't find good places for it. I mean, if I place a try..catch on GetConnection method, for instance, how my ASPX page would get this error? How my ASPX page can tell the difference between "database offline" and "sql syntax error" when executing "userBll.Insert(newUser);".
My problem is mainly placing the exception handlers. I understand I would probably have to change return type of some methods. I didn't change because I believe that will have something with the exception handlers.
Btw, please assume I can't use TableAdapters and stuff like that. I would like to create all layers by myself.
I created HttpHandler class in ASP.NET and configured a website to handle any request with the *.test path.
public class GameHandler : IHttpHandler, IRequiresSessionState { public bool IsReusable { get { return false;
[Code]....
I suspect the problem is that ASP.NET doesn't know these requests sent from javascript belong to the same session and that's why the Session values are lost.
I wnat to aacess this path with images in aspx(design-source) side. I successfully tested this with html controls but it contains error with server controls here is the aspx content [Code]....
i have two text boxes and one button in web form. I need to display the contents of text boxes in a datatable in the same form, when i click on the button.
How can i do this using session array. I need to store values in session array. and get back the values from session when i need .
I am working on Tenant module that has to display following fileds, Tenant Id, Tenant Desc, Contact Person, Contact Phone. In the DB, these are designed as two separate tables - Tenant and Contact. Tenant table has Tenant Id, tenant Desc and Contact Id . Contact table has all the contact related properties. I am using EF as DAL.
To make my system loosely coupled, I have created a repository pattern to talk to EF entities. Also, for validation I am using service layer.
My repository layer has two interfaces and classes corresponding to Tenant and Contact.
public interface ITenantRepository : IRepository<Tenant> // IRepository<T> is a generic interface for CRUD operations { Tenant Get(int id); IEnumerable<Tenanr> List() ;
I am using an SQL Express server hosted on a different machine and it is listed in my server explorer just fine. It is listed as my connection string in my web.config just fine as well and lastly it seems to sync just fine with my asp.net membership tables. My question is does it need to be listed in my app data folder of my site? Currently I have the ASPNETDB.mdf connection listed, which is apparently just a local sql express connection. The database I am using in my webconfig and other files is not listed so do I need to add it there?
Second question is about DAL, Data Access Layers. I have mostly been using presentation level SQL commands with my data presentation controls. Manually entering separate select, insert and update statements. I just went through a tutorial that stated the best way to interact with your database in asp.net is with DAL using table adapters. It mentioned that it gives you the ability to use strongly-typed references to each row. My question is can I use the same method multiple times on a single page. For instance a method inside an adapter named GetProductsByID(@ID) ? What if I want this bound to three different gridviews on a single page? Anyone have any other general things to point out about using DAL over presentation level commands?