How do I reference a Website project

Discussion in 'ASP .Net' started by niberhate, Mar 3, 2010.

  1. niberhate

    niberhate Guest

    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.
     
    niberhate, Mar 3, 2010
    #1
    1. Advertising

  2. niberhate

    niberhate Guest

    On Mar 3, 5:46 pm, 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.


    Maybe it is necessary to add that my IDE is VS 2010.
     
    niberhate, Mar 3, 2010
    #2
    1. Advertising

  3. niberhate

    Scott M. Guest

    "niberhate" <> wrote in message
    news:...
    >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
     
    Scott M., Mar 4, 2010
    #3
  4. niberhate

    niberhate Guest

    On Mar 3, 8:39 pm, "Scott M." <> wrote:
    > "niberhate" <> wrote in message
    >
    > news:...
    >
    > >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?
     
    niberhate, Mar 4, 2010
    #4
  5. niberhate

    Mr. Arnold Guest

    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.
     
    Mr. Arnold, Mar 4, 2010
    #5
  6. niberhate

    Scott M. Guest

    "niberhate" <> wrote in message
    news:...
    On Mar 3, 8:39 pm, "Scott M." <> wrote:
    > "niberhate" <> wrote in message
    >
    > news:...
    >
    > >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
     
    Scott M., Mar 4, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Dob
    Replies:
    2
    Views:
    840
    Rob Dob
    May 23, 2006
  2. dev
    Replies:
    1
    Views:
    605
    S. Justin Gengo
    Sep 12, 2006
  3. Replies:
    3
    Views:
    326
  4. Andy B
    Replies:
    3
    Views:
    324
    Munna
    Jun 12, 2008
  5. Rob Dob
    Replies:
    2
    Views:
    460
    Rob Dob
    May 23, 2006
Loading...

Share This Page