J
jehugaleahsa
Hello:
We here have been working in ASP .NET for a long time now. We have
made tons of successful applications even without knowing the
specifics about the tools. However, the amount of effort it takes to
manage some application features seems way more complicated than they
should. I would like for someone to answer my questions as to how they
do something or how it is intended.
1) Whenever we log a user in, we create a database connection for that
user. Typically, we store the connection (yes, the connection) in the
Session and use a Singleton pattern to retrieve it back later:
public static OracleConnection GetConnection()
{
if (HttpContext.Current.Session["MY_CONNECTION"] == null)
HttpContext.Current.Session["MY_CONNECTION"] = new
OracleConnection("");
return
(OracleConnection)HttpContext.Current.Session["MY_CONNECTION"];
}
However, I am not sure if storing the connection in the session is a
wise idea. It works, but I am becoming wary of sticking anything in
the session. How do you handle database connections, etc. in your
ASP .NET application? Do you recreate a new connection at each
postback? for each query?
2) We noticed that TableAdapters have the ability of persisting across
postbacks. I couldn't examine the source code enough to see how it
worked. My original thought was that Microsoft stored the underlying
DataTable/DataSet in the session. However, I couldn't find it
anywhere. How does MS persist TableAdapters?
3) When navigating around a web site, we typically store table key
information in the session so that we can query information off those
keys. Is it appropriate to store table key information in the session?
You see, I come from the days of POST, hidden fields, etc. I feel
weird putting information in the session like that. But, then again,
what would the session be for?
4) ASP .NET Object Data Sources allow the select command to get its
parameters from many places. However, we here typically have a class
or two that manage our session variables. Similar to the GetConnection
example above, we have a bunch of static methods that retrieve the
session and do our type handling. It is a lot more safe that way.
However, ObjectDataSources don't allow us to get parameter information
from an object or class. Is there a better way of passing parameter
information to an ObjectDataSource?
5) MultiViews can be very useful. But at the same time, they cause
serious issues once the page size gets large enough. We have an
application where modifying the interface is a 15 minute task. We
realized the problem is due to paging and VS storing undo/redo
actions; this causes OutOfMemoryExceptions a lot. Is ASP .NET better
geared toward single page applications with one big MultiView or many
pages linked with session variables? or is there a better way to pass
information around?
6) For some reason, prior to authentication/authorization, the session
dictionary appears to be null occasionally. We have never been able to
figure it out. In some application, the session always exists, but for
some reason, it becomes null in other applications. We are not sure
what causes it. However, we have noticed that it doesn't happen once
the user is logged in. The question is, is there a new session created
once a user logs in? is there a session at all prior to log in?
We need to know because our membership and role provider classes both
need database connections. Where is the best place to store a
connection for a provider class? should we be storing connections at
all? I was thinking in the Application dictionary, since it belongs to
all users.
--
I think that will do for now. Thank you for filling in any of the
holes.
Thanks,
Travis
We here have been working in ASP .NET for a long time now. We have
made tons of successful applications even without knowing the
specifics about the tools. However, the amount of effort it takes to
manage some application features seems way more complicated than they
should. I would like for someone to answer my questions as to how they
do something or how it is intended.
1) Whenever we log a user in, we create a database connection for that
user. Typically, we store the connection (yes, the connection) in the
Session and use a Singleton pattern to retrieve it back later:
public static OracleConnection GetConnection()
{
if (HttpContext.Current.Session["MY_CONNECTION"] == null)
HttpContext.Current.Session["MY_CONNECTION"] = new
OracleConnection("");
return
(OracleConnection)HttpContext.Current.Session["MY_CONNECTION"];
}
However, I am not sure if storing the connection in the session is a
wise idea. It works, but I am becoming wary of sticking anything in
the session. How do you handle database connections, etc. in your
ASP .NET application? Do you recreate a new connection at each
postback? for each query?
2) We noticed that TableAdapters have the ability of persisting across
postbacks. I couldn't examine the source code enough to see how it
worked. My original thought was that Microsoft stored the underlying
DataTable/DataSet in the session. However, I couldn't find it
anywhere. How does MS persist TableAdapters?
3) When navigating around a web site, we typically store table key
information in the session so that we can query information off those
keys. Is it appropriate to store table key information in the session?
You see, I come from the days of POST, hidden fields, etc. I feel
weird putting information in the session like that. But, then again,
what would the session be for?
4) ASP .NET Object Data Sources allow the select command to get its
parameters from many places. However, we here typically have a class
or two that manage our session variables. Similar to the GetConnection
example above, we have a bunch of static methods that retrieve the
session and do our type handling. It is a lot more safe that way.
However, ObjectDataSources don't allow us to get parameter information
from an object or class. Is there a better way of passing parameter
information to an ObjectDataSource?
5) MultiViews can be very useful. But at the same time, they cause
serious issues once the page size gets large enough. We have an
application where modifying the interface is a 15 minute task. We
realized the problem is due to paging and VS storing undo/redo
actions; this causes OutOfMemoryExceptions a lot. Is ASP .NET better
geared toward single page applications with one big MultiView or many
pages linked with session variables? or is there a better way to pass
information around?
6) For some reason, prior to authentication/authorization, the session
dictionary appears to be null occasionally. We have never been able to
figure it out. In some application, the session always exists, but for
some reason, it becomes null in other applications. We are not sure
what causes it. However, we have noticed that it doesn't happen once
the user is logged in. The question is, is there a new session created
once a user logs in? is there a session at all prior to log in?
We need to know because our membership and role provider classes both
need database connections. Where is the best place to store a
connection for a provider class? should we be storing connections at
all? I was thinking in the Application dictionary, since it belongs to
all users.
--
I think that will do for now. Thank you for filling in any of the
holes.
Thanks,
Travis