Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I reference a Website project

Reply
Thread Tools

How do I reference a Website project

 
 
niberhate
Guest
Posts: n/a
 
      03-03-2010
I am working on an existing asp.net website project (not a web
application project). I want to add a unit test project to the
solution, but I don't know how to reference this website project in my
unit test project.

It is easy if it were a web application project because I could select
from the project tab. This website project does not show up in the
project tab. I am talking about the project tab in the Add Reference
dialog box.

Any idea? Thanks.
 
Reply With Quote
 
 
 
 
niberhate
Guest
Posts: n/a
 
      03-03-2010
On Mar 3, 5:46*pm, niberhate <gnewsgr...@gmail.com> wrote:
> I am working on an existing asp.net website project (not a web
> application project). *I want to add a unit test project to the
> solution, but I don't know how to reference this website project in my
> unit test project.
>
> It is easy if it were a web application project because I could select
> from the project tab. *This website project does not show up in the
> project tab. I am talking about the project tab in the Add Reference
> dialog box.
>
> Any idea? Thanks.


Maybe it is necessary to add that my IDE is VS 2010.
 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      03-04-2010

"niberhate" <> wrote in message
news:35640fec-ff14-4a1d-806b-...
>I am working on an existing asp.net website project (not a web
> application project). I want to add a unit test project to the
> solution, but I don't know how to reference this website project in my
> unit test project.
>
> It is easy if it were a web application project because I could select
> from the project tab. This website project does not show up in the
> project tab. I am talking about the project tab in the Add Reference
> dialog box.
>
> Any idea? Thanks.


You'll only be able to unit test the code in the App_Code folder and you'll
need to pre-compile the web site so that the code in this folder gets
compiled into a .dll. Then you can use the "Browse" tab of the Add
Reference dialog to browse for this .dll.

This is part of the price you pay with website projects...their code is
dynamically compiled at runtime. Microsoft and many book and article
authors like to talk a great deal about websites, but the reality is that
for large-scale mission-critical applications, ASP .NET Web Application
Projects are much preferred.

-Scott


 
Reply With Quote
 
niberhate
Guest
Posts: n/a
 
      03-04-2010
On Mar 3, 8:39*pm, "Scott M." <s-...@nospam.nospam> wrote:
> "niberhate" <gnewsgr...@gmail.com> wrote in message
>
> news:35640fec-ff14-4a1d-806b-...
>
> >I am working on an existing asp.net website project (not a web
> > application project). *I want to add a unit test project to the
> > solution, but I don't know how to reference this website project in my
> > unit test project.

>
> > It is easy if it were a web application project because I could select
> > from the project tab. *This website project does not show up in the
> > project tab. I am talking about the project tab in the Add Reference
> > dialog box.

>
> > Any idea? Thanks.

>
> You'll only be able to unit test the code in the App_Code folder and you'll
> need to pre-compile the web site so that the code in this folder gets
> compiled into a .dll. *Then you can use the "Browse" tab of the Add
> Reference dialog to browse for this .dll.
>
> This is part of the price you pay with website projects...their code is
> dynamically compiled at runtime. *Microsoft and many book and article
> authors like to talk a great deal about websites, but the reality is that
> for large-scale mission-critical applications, ASP .NET Web Application
> Projects are much preferred.
>
> -Scott


So, looks like Website project is really bad for those who do TDD's.
Can we precompile the Website project and then refer to the resulting
dll outside of this Website project?
 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      03-04-2010
niberhate wrote:
> I am working on an existing asp.net website project (not a web
> application project). I want to add a unit test project to the
> solution, but I don't know how to reference this website project in my
> unit test project.
>
> It is easy if it were a web application project because I could select
> from the project tab. This website project does not show up in the
> project tab. I am talking about the project tab in the Add Reference
> dialog box.
>
> Any idea? Thanks.


You would create a new Web application project. You remove the new
project from the 'Solution'. You right-click the Solution Name line and
select Add and Add an exiting Web site, which I will assume isa on
Localhost.

Now, you have a solution that has a project of //localhost.Website. You
can then add new projects to the solution file

But as far as you setting some kind of project reference pointing to the
//localhost.Website as a reference to another project within the
solution file is a no go -- you can't do it. You can set a project
reference in the //localhost.Website project to a project in the
solution like a classlib project.

But as far as you doing some kind of Unit or Functional test with a test
harness like MBunit, Nunit or others, you can't do that type of test
against a Web site.

You would unit test against a classlib project that was hosting a MVP or
MVC that worked with the Web UI testing against interfaces of the MVP or
MVC.


 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      03-04-2010

"niberhate" <> wrote in message
news:b9d08c4c-c61a-4008-8bd1-...
On Mar 3, 8:39 pm, "Scott M." <s-...@nospam.nospam> wrote:
> "niberhate" <gnewsgr...@gmail.com> wrote in message
>
> news:35640fec-ff14-4a1d-806b-...
>
> >I am working on an existing asp.net website project (not a web
> > application project). I want to add a unit test project to the
> > solution, but I don't know how to reference this website project in my
> > unit test project.

>
> > It is easy if it were a web application project because I could select
> > from the project tab. This website project does not show up in the
> > project tab. I am talking about the project tab in the Add Reference
> > dialog box.

>
> > Any idea? Thanks.

>
> You'll only be able to unit test the code in the App_Code folder and
> you'll
> need to pre-compile the web site so that the code in this folder gets
> compiled into a .dll. Then you can use the "Browse" tab of the Add
> Reference dialog to browse for this .dll.
>
> This is part of the price you pay with website projects...their code is
> dynamically compiled at runtime. Microsoft and many book and article
> authors like to talk a great deal about websites, but the reality is that
> for large-scale mission-critical applications, ASP .NET Web Application
> Projects are much preferred.
>
> -Scott


>So, looks like Website project is really bad for those who do TDD's.
>Can we precompile the Website project and then refer to the resulting
>dll outside of this Website project?


The only benefit of a Web Site is that you don't have to worry about all
your code having to compile into one .dll. They were invented for those
developers who wanted a finer level of granular control over the files and
assemblies in their work. But, the ramifications of using them make them
not very suitable for business application development. I don't know of any
company using them for Enterprise development. There was such a backlash
from developers when VS 2005 initially shipped without the Web Applicaiton
Project type and only the Web Site, that MS put it back into VS 2005 SP1 and
then VS 2008 and VS 2010.

If you do precompile your App_Code folder's stuff into a .dll, then you can
use the Browse tab of the Add Reference dialog to reference it from any
other project. But, if you are going to need this functionality in other
places, you may want to consider making a stand-alone class library or
component that can be used in both projects.

-Scott


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Reference classes of a website project Tem ASP .Net 11 02-08-2008 03:25 AM
Make a Reference from a project to a website in the same solution skneife@gmail.com ASP .Net 3 12-13-2007 05:57 PM
Automatic update web reference in WebSite project dev ASP .Net 1 09-12-2006 01:49 PM
How to tell if a reference is project or file reference from within the IDE? Darren ASP .Net 0 10-11-2004 12:51 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57