How To Access The Session From A Different Project Within The Solution

Feb 4, 2010

I have 2 projects in my solution.

MVC Web application
Class library

The MVC Web application references the class library.

The class library contains a class that extends the default ASP.Net Controller.

I'm putting a variable in session in the application's Global.asax.

protected void Session_Start(object sender, EventArgs args)
{
HttpContext.Current.Session["DomainName"] = Request.Url.Host;
}

In the class library I'm trying to get the value from the HttpContext.Session, but HttpContext.Session keeps coming up null.

[code]...

HttpContext.Current.Session doesn't seem to be an option in controllers.

View 3 Replies


Similar Messages:

How To Structure A Utility/companion Project In A Multi-project Solution

Aug 4, 2010

Let's say I have a Visual Studio solution with a Web project, a BLL project, and a DAL project. I'm trying to follow the repository pattern keeping my SQL code in the DAL with an interface that is referenced by the BLL.

I have a handful of common solutions for things such as error handling, usage logging, and other things that can be considered utility functions (i.e. not in the business spec). I'm keeping these in a Common project.

Here are a few ideas I've had with regards to structuring the Common project...

Bundle SQL with logic in a given class

Create a layered solution within the Common project

Discard the Common project and put utility functions in with BLL/DAL

Is one of these ideas better/worse than the other? Does anyone have a better solution?

It's worth noting that these utility functions will be reused in a variety of other applications.

View 1 Replies

How To Access Session Object Outside The Web Project (class Library)

Oct 29, 2010

I am implementing a custom membership and role providers where I need to store all the role/membership information in the user's session.

I am implementing these custom providers inside a class library project (different from the website project) and need to access the session in them. The idea is to store the role/membership related information in the session after retrieving them for the first time from the database.

When I try to access the Session using System.Web.HttpContext.Current.Session

I get this as a null object (Object reference not set to an instance of an object.

Why is the session turning out to be null?

View 1 Replies

How To Generate Solution And Project File From Project

Mar 4, 2010

i have the project files which consist of some folders and some aspx and aspx.vb files.

I do not have any solution file or .sproj file in it.

so I need open a single file at a time and I can not debug the whole project or any single file also.

Do I have to generate a project file or solution file,

I just wanted to open the whole project file by opening a single file in VS 2008.

so that all the folder structure and the files I can view in solution explorer.

View 1 Replies

MVC :: Using Model Outside Of Project But Within Solution

Feb 16, 2011

I have decided to go back to an old project that I had placed on hold, to get familiar with MVC 3 Razor. It is a Jokes website (some of you already know). I have been watching these video tutorials on Code First Entity Framework 4, and I have managed to build my model in a project of its own. Then I went and created another project (this time MVC 3 Razor Blank Project) and linked the two togther. I am trying to simply list the joke, but I get the error saying:

CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
public class _Page_Views_Home_Index_cshtml : System.Web.Mvc.WebViewPage<IEnumerable<LNModel.Joke>> {

Here is the code in my HomeController:

[Code]....

I know what the error means, I am missing a { using System.Data.Entity; } statement somewhere. But I can't understand why ! according to the video, if I have referenced my projects to that statement, I shouldn't be having this problem !

View 15 Replies

MVC :: Cannot Add MVC 3 Project To Empty Solution

Dec 16, 2010

Scenario:

1) Create completely empty VS 2010 solution.

2) Add one project. Now there's one project but no solution root.

3) Choose "Add new project" from the file menu.

4) Add MVC 3 empty project

5) It fails because the current "something" is neither the solution nor a solution folder.

Workaround: create two other projects first.

View 2 Replies

How To Get RESX Value From Other Project In The Same Solution

Oct 6, 2010

I have two projects in the same solution:

My.Solution.name.with.dots

BLL

Web

in the BLL project, I create a class that need to get a global resx value from RESX file that is placed in the Web project. Is it possible ?

BLL can't have a reference to Web project because of the project dependency

View 1 Replies

Configuration :: How To Add A New Project Into The Solution

Apr 24, 2010

There is a solution that whithin it I have a web project.

Now, I wish to add a new web project which has it's own App_Data,App_Themes.App_Code.

I don't wont to mess things and combine them both in the same project. I just won't to compile the new project and upload it sepretly to the web server in a different directory.

How do I do that with VS2008?

View 1 Replies

How Many Web.config File Does A Solution/project Can Contain

May 26, 2010

How many web.config file does a solution/project can contain?

View 6 Replies

C# - Make New Project And Website Into Only One Solution?

Apr 24, 2010

How to make new project and website into only one solution?

View 2 Replies

Web Forms :: After Added Already Existing Project The Solution Icon Vanished By Showing The Icon Of Recently Added Project?

Feb 1, 2010

I have the following list of projects WebUI (WebSite) , DataAccess (ClassLibrary) , LogicLayer(ClassLibrary). Those of the project are purposively crated separately.But my scenario is, need to create only one solution file, then add all of the above projects under this solution file. So that i can be easiy interacted and changes can be made by opening solution file only instead of opening each project individually.

Simply all of the layer projects are under one roof means one solution. I tried it by adding solution first, then i added already existed project into this. But once after added already existing project the solution icon vanished by showing the icon of recently added project. By this way I could not add another project into this section too.Hope this is the way the basic real-time projects are created; to achieve the centralized control over architecture based projects.

View 4 Replies

Visual Studio :: How To Create A Solution With Project

Aug 12, 2010

I have to modify a exist web application in Asp .Net, the problem is that I have the application just on the server.

I copy the application on my pc but now I have to create the appropriate solution and project to modify it.

I've all the file .cs and the dll already deployed.

How can I create the web application with .net ?

View 1 Replies

Auto Compile Sub Project Of A Website Solution?

Feb 25, 2010

Is to possible to make a configuration entry (web.config). That automatically compiles a referenced project(for example a class library) when the site runs? This would be easier for me to maintain on my hosting server. Otherwise i have to always recompile the files and upload them again for every small change.

View 1 Replies

How To Consume An EF Model In A Seperate Project Within A Solution Correctly

Nov 29, 2010

I am trying to find a way to have my Entity Framework model in a seperate project within my ASP.NET solution.

Currently I have my DataManager project (which contains my EF model and some classes) and a second project which contains all my web project files.

The problem that I have come across is that I have a database connection string in a App.Config file in my DataManager project and the same connection string in my Web.Config from my web project. I basically have a duplicate connection string.

Is there a way to only use only one connection string in my project (preferably from my web.config)?

My only concern is that when it comes to compiling my project I will not be able to change the connection string in the App.Config contained in my DataManager project.

View 1 Replies

Visual Studio :: One Project In Solution Opens As Website Not Web App?

Feb 24, 2010

this seems to be a problem only on my new PC, not my prior PC or my coworkers PCs. But, as far as I know, I have installed VS2005 the same way, including the VS80-KB915364-X86-ENU.exe and WebApplicationProjectSetup.msi additions.

I have a VS2005 Solution called 'Intranet' made up of several web projects. One of those web projects is also called 'Intranet'. All of the projects should load as Web Application Projects, which they did on my prior PC.

Now, the 'Intranet' project seems to be opening as a Web Site project. The name of the project in the solution now shows as "C:...Intranet" instead of just "Intranet" and is not recognized as being part of the SourceSafe project(no lock icon shows). If I right-click this project, "Build Web Site" is one option.

View 3 Replies

Visual Studio :: Can't Change The Code In Solution (Project)

Oct 14, 2010

I have problem using Visual Studio.NET 2003. When I open solution made early ago, choose the code of the existing .aspx page, could not change it, because when type nothing happened, no letter, no sign, like the keyboard is "dead" (but it is not, ofcourse).

View 6 Replies

Visual Studio :: Pass Values Between Different Project In Same Solution?

Jan 21, 2011

I have a solution file with 2 projects inside, one will be handling the presentation portion and the other is for database data retrieval. I was wondering if its possible to pass a value from the presentation.aspx in the "presentation" project to the db.aspx in the "database" project? They are both in the same solution file.

View 8 Replies

C# - Using Web Service In Class Library Which Is Referenced In The Website Project Of Same Solution?

Nov 18, 2010

How to access proxy class of a web service which has been referenced in the website project of a solution within a class library project in the same solution?

I mean no web-service reference/setting is added to the class library and instead it needs to be picked from the web project.

View 1 Replies

Visual Studio :: Convert 2003 Project - Get Solution Is Unavailable?

Sep 13, 2010

I have three folders , which original is build by vistual 2003 , recent ly I install vistuall 2005 on Win 7 and succesful covert one folder from vistual 2003 t0 2005 ( I forget how , I am new on win 7) , when I deat with my second folder I always get Test2( unviable) under the Solution Exporer ( vistual 2005) But I can access this folder by brows( when I try http://localhost/test2/) I get all the files under this folder , why I can see them on my vistual studio 2005???

View 6 Replies

Unit Testing - NullReferenceExpection In A Integration Test Project For A Nhibernate Solution?

Nov 19, 2010

i have a .NET 3.5 solution with an asp.net(web site) project with fluentnhibernate and it's test project(class library project).i've referenced the asp.net project in the test project and with all fluentnhibernate/nhibenate dlls.

What i fail to comprehend is that, on a run of a webform (hit from browser) let's say Test.aspx, building of schema is successfull and i could see the tables in my database.

here is the method i call on Test.aspx.cs

[code]....

So from my comment the NullReferenceException happens when accessing the connectionstring. I don't have the explanation on why that happens.

View 2 Replies

C# - Calling Membership Validateuser Method From Another Project In Same Solution Throw Null?

Oct 25, 2010

I have a webservice project and a web project in the same solution.

The web project implements a membershipprovider.

I want to be able to authenticate user via the webservice project but when i call this method in the webproject:
public static bool AuthUser(string userName, string password)
{
return Membership.ValidateUser(userName, password);
}

I get this inner ex."Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed." Calling the method from the webproject works fine. I understand why I get the ex. but not how to solve it.. UPDATE Well I fixed the issue by deleting the C:UsersJRBAppDataLocalMicrosoftMicrosoft SQL Server DataSQLEXPRESS folder.. However now the method always returns false.. It almost seems like it doesn't use the proper connectionstring.

View 2 Replies

Visual Studio :: Can't Launch New Project Or Solution Of Any Type - Error Message

Jan 7, 2010

I cannot get beyond the following error message when trying to load any new project or soultion of any type:

View 2 Replies

Setting Cookie Expiration With ASP Classic To Session Sharing Solution

Jun 25, 2010

I'm implementing the session sharing structure from this link for an ASP classic site to begin the gradual conversion process to ASP.NET. I'm trying to extend the cookie expiration time so that users do not get signed out of the site when the session expires. At the place where the cookie is created in SessionPage.cs I've added the line in the CreateNewSessionCookie() method: cookie.Expires = DateTime.Now.AddDays(14);

Now this works fine, however, it only works if the user first visits an ASP.NET page, and then visits the ASP classic pages. It doesn't work if visiting an ASP classic page first (looking at the cookie through firefox confirms that different expiration values are given based on if I visit an ASP or ASP.NET page first.) I'm still a bit fuzzy on the mechanics behind this implementation as I don't have a complete understanding of session and cookie handling. However, I would have thought that the VB6 SessionMgr object is calling the SessionUtility DLL, and thus is using the same code to issue the cookie. I have re-registered the SessionUtility using gacutil, and re-exposed it using regasm. How else is the cookie being issued when a user accesses an ASP classic page? How can I change the expiration time?

View 1 Replies

Website Type Project No Solution Is Created And No Link Is Created With IIS?

Feb 12, 2010

onething is not clear to me that in asp.net 1.1 there was asp.net project type but from 2.0 there is no asp.net project type option rather

there is option called website. in website type project no solution is created and no link is created with IIS.

why microsoft design in this way from 2.0. i think there must be soldin reason & advantage behind it.

View 4 Replies

How To Access Webservice From One Project To Another Project

May 10, 2010

i have an project with name called(dbservice layer) which is in path: d:webserviceDBService. here i have an webservice which connects to DB and returns an object of an class.

once i added an reference here i get an url:http://localhost:2371/Jobs.svc

now i have another project name (UILayer) whic is in path: E:SchoolUILayer i added an service reference here with url as http://localhost:2371/Jobs.svc but i get an messgae telling service is unable why is that happening.

if both my webserivce layer and ui layer are in same project. then i able to use the webserive in the ui layer. and get the required output

so i wanted to know is there any way we can acesss the webserive from one project to another project

View 1 Replies







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