Reference aspx pages from different web project - asp.net

I have an ASP .NET web form solution with multiple web projects. There is one core web project and each of the other web project work as pluggable modules.
I have written a post build event to copy aspx/ascx files and *.dll of child web projects to the core web project directory.
The issue is - I am not able to call child project aspx pages from the core project. I get "Could not load type" error.
Is it possible to use aspx pages in different project if i refer that webproject dll and copy the aspx files to the main application? What am i doing wrong here. I would greatly appreciate any pointer in the right direction. Thank you.
Sanjay

I found answer to this. The key is to define you assemblies in the web.config file and then define a probing path. Following is the link with details-
http://weblogs.asp.net/chrismoseley/archive/2008/10/28/shared-assemblies-without-the-gac.aspx

Related

How to create redistributable user control in DLL form with embedded images, javascripts, style sheets?

I've developed a most reusable ASP.Net WebUserControl for our company's web applications. I'm now going to make it as a redistributable DLL according to this msdn topic. Since the WebUserControl comes with some JavaScript(s), CSS(s) as well as images. I'm asking how can I bundle them all together to form a single DLL?
Our development environment is Visual Studio 2008, .Net Framework 3.5
Please kindly advise!
Thanks!
William
You could bundle the non source code parts in a resource file and reference them through there in your ASP.NET code. You could add to the default resource file (.resx) or add your own..
I haven't actually tried this but I think you could embed the user controls, JS files, etc into the output assembly of your reusable library project. Basically in the Properties dialog you'd set the "Build Action" to "Embedded Resource" for those files instead of "Content".
Then the consuming application would implement and register a VirtualPathProvider to tell ASP.NET to look for user controls inside the assembly.
Here's a similar question dealing with loading MVC Views from a DLL, same idea: Using VirtualPathProvider to load ASP.NET MVC views from DLLs
And this: http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/

what is the difference between creating a web application and a web site?

Why does an assembly get created when I am building a web site? I mean a web site and not a web application.
The difference is quite big. A web site is not compiled. Code is placed in the App_Code folder and dynamically compiled by ASP.NET at runtime. A web application is precompiled meaning that you can place code wherever you want and it will produce an assembly at compile-time. You also get a project file .csproj associated with it.
Here's an overview on MSDN.

How do I specify the name of the assembly created when publishing an ASP.NET Web Site Project?

The title pretty much says it all.
Given a web site project in VS2008 named FooDLL, I would like to be able to specify the name of the assembly that VS2008 spits out when I click "Publish Web Site". I am using the "use fixed naming and single page assemblies" option, so the resulting DLL is consistently named.
However, I would much rather be able to specify that the DLL is named something like FooDLL.dll (or just Foo.dll, whatever) than be stuck with the ugliness of App_Web_foo.ascx.cdcab7d2.dll.
Am I stuck since Web Sites don't have .project files (e.g. aren't projects)?
Not to continue the pattern of answering my own questions, but here it is anyway:
All I had to do was add a Web Deployment Project for the web site containing my user control. Though you can't specify the assembly name when building/publishing a web site, you can do this through the web deployment project. It's basically just a nice GUI for an msbuild project file... for a web site. Hooray for hacking a .project file onto a web site!
You could just compile your code as a class library project, then drop it into the Bin directory of your website.
I believe you are.
I am unaware of any benefits to using a web site project and while the benefits of using a web application project are minor, they exist. Create web application projects from now on.
ASP.NET Merge Tool (Aspnet_merge.exe) is your way to go.
It merge your web assemblies into one assembly for the whole Web site.
more information:
http://msdn.microsoft.com/en-us/library/bb397866.aspx

Deploy asp.net application without compiling DLL

When I publish any type of asp.net application, my code is precompiled into various assemblies. I would like to avoid this so that I can upload an aspx page and its corresponding codebehind file. I understand the benefits of doing it either way, but what is desired here is the least risky way to publish changes.
How does one properly deploy an asp.net project without compiling assemblies?
Is the process different for each model (web app, MVC..)
Sounds like you have a Web Application Project, and what you want is a Website Project. With website projects, you can modify the aspx and codebehind files and not have to worry about recompliling them, asp.net will do that for you. Web Application Projects need to be compiled for every code change.

Is dynamic compilation in a 'ASP.NET Web Application' possible?

Can I somehow utilize the App_code folder in a web application project to compile code on the fly? It'd be great for plugins. Recently Rob Conery demonstrated its use in his talk at MIX 09 in a ASP.NET MVC app. I tried to do the same in a web app but I can't access the classes under App_Code from anywhere else. But if Rob was able to do it in an MVC app, it should be doable in a web application too. After all ASP.NET MVC IS a ASP.NET Web Application under the covers.
If you add a code file to the App_Code folder, it should be compiled and available from a code-behind file for a control, or another code file in the App_Code file.
I don't think you'll be able to access it directly from a compiled assembly, since the compiler won't be able to find that reference at compile time.
You'll also need to be aware that App_Code is compiled into a different assembly than your code-behind code, so you can't access internal code across the different assemblies.

Resources