Web Forms :: Creating Application Level Session Object?
Mar 24, 2011
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.
View 4 Replies
Similar Messages:
Jan 31, 2011
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.
View 4 Replies
Jan 21, 2010
Environment used - Asp.net mvc 1.0 with c#
Problem -I have used simple mvc application. and also added webform into mvc application.and it is working fine. but when i used session object for sharing data between mvc and webapplication. it is not working. I have put Session["logon"] = "logon"; object into mvc controller and when i access this into webform then there is no value in session object.
View 2 Replies
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
Feb 10, 2010
I want to create a three level menu, I have got a recursive function today that works with three levels. But the thing is how do i output the third lever? Using two repeaters i have managed to get a hold of the first two levels through the ChildNodes property. But that only gives me the second level. What if a want the third level? Example code below. How do i get the third level? :)
<asp:Repeater ID="FirstLevel" DataSourceID="SiteMapDataSource" runat="server" EnableViewState="false">
<ItemTemplate>
<li class="top">
<a href='/About/<%#Eval("Title")%>.aspx' class="top_link"><span class="down"><%#Eval("Title")%></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
<asp:Repeater runat="server" ID="SecondLevel" DataSource='<%#((SiteMapNode)Container.DataItem).ChildNodes%>'>
<HeaderTemplate><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"></HeaderTemplate>
<ItemTemplate>
<li>
<a href='<%#((string)Eval("Url")).Replace("~", "")%>' style="text-align: left;"><%#Eval("Title")%></a>
Third repeater here?
</li>
<ItemTemplate>
<FooterTemplate></ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
View 2 Replies
Mar 16, 2010
I have a multilevel Category Table, like so
CategoryID, CategoryName, ParentCategoryID, IsMainCategory
I want to be able to loop through all the categories starting with the Main Categories and then go all the way down for example I could have
[code]...
I wanted to be able to loop through ALL categories in order like above programatically - This is how far I got
[Code]....
But I hit a stumbling block.. I just wanted to check I am tackling this the right way? Or is there something simple I'm missing?
View 2 Replies
Nov 15, 2010
In the VS2005 environment, when I test my session to make sure the page redirects to the main page (itself) if the session is null, it works. There is no error.
The function I use for this is:
[code]....
However, when it is in the production environment in IIS 6.0, when the session has timed out, and I then do a postback by doing some slider control, I see the page reload but immediately thereafter, it throws a Server Error exception of : Object reference not set to an instance of object.
Looking at the stack trace, the event occured:
AJAXEnabledWebApplication1._Default.Slider1_TextChanged(Object sender, EventArgs e)
however, why is it that the Slider1_TextChanged event fired even even after during page_load, the page was told to do a response.direct ?? shouldn't the entire page have gone through a full-page refresh life cycle ? why did it continue on to attempt to raise the Slider1_TextChanged event?
View 1 Replies
May 7, 2015
I am getting object refernce error at line:if (Session["Tax"].ToString() == "9")
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Tax"].ToString() == "9")
{
lblTax.Text = Session["Tax"].ToString();
}
else
{
lblTax.Text = "0";
}
}
Is anything wrong I have done?
View 1 Replies
Feb 3, 2010
How to remove the unused references in form level, vb.net application and web application?
How can I use fxcop to identity undisposed objects like dataset, dataview, connection, stream...? Any one having custom rules for the same?
View 1 Replies
Nov 28, 2013
How to start Quiz application in advance level objective only.
having following functions
Multiple Choices Answers
Subject wise
Location Wise
Score based
Different level[easir to difficult]
Specify No of Answer etc
View 1 Replies
Apr 20, 2010
I´m trying to build a site : http://muralhas.siteparaver.com/ with a login and a password, but when i log i get this error:
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error: [Code]....
View 2 Replies
Nov 30, 2010
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.
string sessionCookieName = ((SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState")).CookieName;
View 1 Replies
Jul 28, 2010
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.
<sessionState mode="InProc" cookieless="true" timeout="180" />
View 4 Replies
Jun 28, 2010
We are working on a drill up/drill down application. The drill functionality is provided by the dropdown list box. The data breaks down during drill down and roll ups during drill up (sum and averages)
We have used the gridview (which is not databound) for data presentation to generate a column during each drill level to indicate the current drill level.
At one particular drill level, a hyperlink has to be provided for an existing field on the data, to display its details.
Can hyperlink be provided in a gridview that is not databound?
Can a hyperlink control be created in a gridview during runtime (when the specific drill level is selected in the drop down list box)?
As a solution to this problem, we created a databound gridview, with the hyperlink for the required column and made it visible for that particular drill level.
View 4 Replies
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)
View 2 Replies
Feb 15, 2011
I've got a multi level dependency chain in my object model: An organization has the following children relationships:
Organization
.CompetitionGroups
.CompetitionGroups.Venues
.CompetitionGroups.Competitions
.Divisions.Games
.Divisions.Games.Participants
.Divisions.Games.Participants.GameSegments
.Divisions.SubDivisions...
.Divisions
.Teams
.Teams.Players
.Teams.Participants
.Teams.Participants.GameSegments
.VenueDates
This is just a glimpse at the object model, but it's focused on the complexity of the relationships and lists. What I can't really get is what's the best way to factor my repository interfaces, given the requirements to do a unit of work. For example, to create a game, you'll need a venuedate and two participants. Does that mean the GamesController should require an IGameRepository, an IVenueDateRepository, and an IParticipant repository? Should they be rolled into one repository?
Also, what about in the consumption cases? For example, to display a signle team's schedule, you'll need all of the Participants for that Team, all of the Games for that participant, and all of the GameSegments for the participant. If those are factored into individual repositories I can't see how you can do efficient queries. Does that mean you have Repositories specifically focused on different cases? for example:
public interface IScheduleRepository {
public ICollection<Game> GetScheduleForTeam(Team team);
// More consumption methods
}
public class ScheduleRepositry : IScheduleRepository {
public ScheduleRepository (ModelContext context) {
// Do stuff with context
}
public ICollection<Game> GetScheduleForTeam(Team team) {
return (
from p in context.Participants
where ((p.Game.VenueDate != null) &&
(p.TeamId == team.Id))
orderby p.Game.VenueDate.StartTime
select p.Game).ToList();
}
// more consumption methods
}
public interface IGameRepository {
public void AddGame(Game game);
// More crud methods
}
// Not showing games repository
public class GamesController : Controller {
public GamesController (IGameRepository gamesRepo,
IVenueDateRepository venueDateRepo,
IParticipantRepository participantRepo) {
// do stuff with repos here
}
[HttpPost]
public ActionResult AddGame(Game game) {
// Skipping validation logic
// this?
VenueDate = venueDateRepo.Add(game.VenueDate);
foreach (Participant p in Game.Participants)
{
participantRepo.Add(p);
}
Game = gamesRepo.AddGame(game);
// or this?
// how would the game repo know to persist
// the children elements? is that tight coupling?
Game = gamesRepo.AddGame(game);
}
// more consumption methods
}
My question is I don't yet understand to what degree factoring your repositories make sense based on a connected object model. I'd love to get some advice here.
View 1 Replies
Jul 20, 2010
I am confused about how to reference objects in session, how to update, and copy.
if I create
MyObject obj = new Object ();
then
Session["object"] = obj;
MyObject temp = (MyObject)Session["object"];
If i change something on temp, will the object in session be updated? do i need to follow changes with Session["object"] = temp?
View 2 Replies
Oct 7, 2010
I want to be able to persist data across a session but do this outside of the built-in session state object. Why is a long story that I will not go into here. I just need to know where I can put data other than in the session object that will persist across the specific session.
View 3 Replies
Apr 11, 2010
My ISP recently has migrated my app to a new platform. The app has now to be parked in a root subfolder, say site1, rather than at the root.
The main page can still be accessed via [URL] is now located at /site1/default.aspx. Subfolder pages however cannot be accessed correctly anymore since the url includes now subfolder name "site1" ie
[URL]
instead of
[URL]
This of course breaks page referencing.
Despite multiple requests, I have not yet obtained an answer so far. Question: Is there a simple way to strip away string "site1" from the url, preferably at the web.config level? I know this can be done programmatically at the page level, to clean up page references (>30 pages). In addition, this could entail further compatibilty problems between the deployment version and the local development site.
View 3 Replies
Nov 9, 2010
My web application is composed of several Visual Studio projects. It currently runs fine under high trust level (<trust level = "High" />). When I try to run it under medium trust level, I get this error:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.Security
Exception: Request failed.
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:
[SecurityException: Request failed.]
System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark, Boolean loadTypeFromPartialName) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark) +64
System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark) +58
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +342
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +52
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
What is the best way to identify the problem and convert the application to run properly under medium trust?
View 1 Replies
Oct 18, 2010
I used MicrosoftReportview in my project , The reports are avalable in project folderWhen I run web site in Server (not VS development server) . It give this type of error.Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The element 'buildProviders' cannot be defined below the application level.
<add assembly="Infragistics2.WebUI.WebSpellChecker.v7.3, Version=7.3.20073.1043, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
[code]...
View 1 Replies
Sep 14, 2010
I have a need to add an application level event (like Application_Start) but not in global.asax. The reason that I can't use global.asax is because this is a web application for which I don't have source code but I want to add some functionality to it. I need to insert an application start code and was wondering it there was anyway to do it. I'm not sure that if I add a class or aspx page to the sie if it will dynamically compile since this is a web application.
View 8 Replies
Oct 7, 2010
I am working on a ASP.NET MVC 2.0 Multi-Presentation web application which would use a common codebase to support different websites. These websites would differ in following aspects:
Each website will have their own headers, footers, images, CSS etc (I guess website specific Master Pages)
Some of the UI elements could be different based on soft-coded settings at website level
What is the best approach to handle these requirements? Should I be storing these website level soft-coded settings in Database or multiple config files? I might have to provide a admin UI to manage these soft-coded settings. How do I access these settings in different layers (MVC, Services, Repositories etc) of my application?
View 1 Replies
Feb 19, 2010
I am about to deploy an ASP .NET application (developed with LINQ-to-SQL). I have taken following precautions: Database access via user with limited access, however, since application is to access the sensitive data, I can't deprive this limited access user from it Database server is not exposed to external network - is hiding behind DMZ and all external ports are blocked I have done thorough security testing of the web-application; SQL Injections, rights management, illegal data access (via post/get data tempering) Application is operating on SSL
1 - I am using ASP .NET authorization API; any recommendation for avoiding session hijacking (in case someone some-how gets to know the session key). Is there are way to change the authentication cookie less prone to threats? Say like, changing it after every request? (I know I am get very conscious about this particular item)
2 - Data in the database is not encrypted. To make things ultra-secure, I am thinking about implementing transparent data encryption. Can someone share his/her experience or a link about implementing data level encryption with SQL Server 2008 along with pros-and-cons?
3 - Recommendation for storing connection string in web.config. Is using integrated security better then using encrypted database connection string?
View 3 Replies
Mar 1, 2010
I have downloaded the online project in ASP.Net. While running application I get an error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS".
What changes should i make in web.config or elsewhere to make this work?
View 4 Replies