Access to ASP.NET User Control in same solution but in different website.....???


I have a user control that I want another site to access. So I have created 2 websites within one solution, one with the User Control (Call it "Server") and another that accesses it(Call it "Client"). If I creat a webpage in "Server" and drag the UC to it, it works. If I create a webpage in "Client" and then drag the "Server" UC to it, it cannot find the UC.

I am aware that one cannot use UCs across completely seperate website, but I sort of thought that if the websites were part of the saem solution then it would be possible.



Who is Participating?
nomooseConnect With a Mentor Commented:
Hey Sam,
 You should probably make an "ASP.NET Server Control" project and put both your controls into that.  Then add a reference to it in both the client and server projects.  From there you should be able to register the assembly and add the controls to both projects.
Let me know how it goes,
SamJollyAuthor Commented:
Another thought I had on this was to convert the UC to a custom control. However the slight complication here is that the UC inherits a few classes from the "Server" website. Perhaps there is a could way to "Package" up all relevant "Associated" code for the new Custom Control. Perhaps there is a utility or certainly some technique.

Thoughts please ????

SamJollyAuthor Commented:
Hi Elliot,

I have just tried this route today. Basically I precompiled the "Server" site as "single Page Assembly" and then added a reference to the relevant DLL from the "CLient" site which worked so far. But it seems the "reference" takes a copy of the dll and the code runs in the context of the "CLient" site. So what happens to the Database connections that are defined in Web.Config in the "server" site? Also if there are redirects in the CBH then it would expect to find those redirects in the "Client" site. Also I noticed that all the inherited code dlls were copied over. This is looking quite a closely coupled approach to linking site functionality. However my assumptions on how this stuff works may be wrong.

From a conceptual point of view I like a more loosely couple approach and the use of IFrames seem simple and pragmatic.

I know the ideal approach is web services, but this is much more involved.


SamJollyAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.