Single DLL - How to get rid of ASPX files?

G

Guest

I'm using a Web Deployment Project under Visual Studio 2005.

What I would love to be able to deploy to a fresh server is just the \bin
folder and the web.config (and perhaps a couple of other support files). But
essentially I don't want to have to deploy all the ASPXs, images, .js etc.

Is there a way to achieve this?

I seem to remember some sort of special ASP.NET marker file you could put in
the application root which would tell it to get all the ASPX content from the
DLL. Did I dream it?

Thanks,
- Boris Y
 
C

Cowboy \(Gregory A. Beamer\)

The ASPX files, with a dll compile, are placeholders. If they are not there,
you get a 404. If they are, the DLL has smarts to find the pointer in code.
It is an unfortunate side effect. AFAIK, if you want to completely get rid
of them, you would need to create your own handler that redirects the 404.
 
G

Guest

Boris Yeltsin said:
What I would love to be able to deploy to a fresh server is just the \bin
folder and the web.config (and perhaps a couple of other support files). But
essentially I don't want to have to deploy all the ASPXs, images, .js etc.

Is there a way to achieve this?

Yes, open a command prompt and cd to your 2.0 framework folder (something
like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727) and use
aspnet_compiler.exe, like this:

aspnet_compiler.exe -v /VirtualDirName -p C:\ProjectPath C:\OutputFolder

You can then copy the contents of C:\OutputFolder to the virtual directory
/VirtualDirName on your IIS server. Remember to make sure the virtual
directory is set to use v2 of the .net framework, or you'll just get
placeholder text (as all the aspx files still exists, they are just blank)
 
G

Guest

OK, this is similar to the standard publish function. It's almost there though.

Some issues:

1) There are assemblies (DLLs) for each file in the bin folder, not just a
single DLL for the web site

2) My external resources (Images, JavaScript files) are not compiled into
the DLL

So, if we can find solutions to these, we'll be rocking!

Thank you,
- Boris Y
 
B

bruce barker \(sqlwork.com\)

the default compile is a dll per page. ms has a utility to merge them into
one dll. you can get rid of images by inserting them into a resource, and
changing all reference to a resource reference (though there is a
performance cost for having asp.net serve images rather than iis)

-- bruce (sqlwork.com)
 
G

Guest

OK, let's take this one step at a time. We'll worry about the resource file
issue afterwards.

I've run:
aspnet_compiler.exe -v /VirtualDirName -p C:\ProjectPath C:\OutputFolder

So now I have a project which has no ASPX files, a whole lot of .dll and a
whole lot of .compiled files in the \bin folder. Works great.

So, now I run:
aspnet_merge.exe C:\OutputFolder -o MyProject

And that creates a single .dll from all the .dll files in the \bin.

I still have a huge supply of .compiled files in the \bin though (one for
every ASPX).

What can I do about these?

Thanks,
Boris Y
 
W

Walter Wang [MSFT]

Hi Boris,

The .Compiled file is a marker file for each page and control in the Web
site and identifies the class used inside of the assembly. These files are
not optional as they map the ASPX pages to the appropriate precompiled
classes in the precompiled assemblies. If you remove the .Compiled file,
the page that it maps will not be able to execute and you get an execution
error.

However, you could remove the .ASPX file marker file if you're not using
Windows Authentication. If you need to set specific Windows file rights on
a directory or specific file, an actual file must exist in order for
Windows Authentication to work. If you don't use Windows Authentication in
your Web application, these marker files can be removed and you can run
entirely off the files in the BIN directory.

You can find an excellent article about ASP.NET Compilation and Deployment
here:

#Compilation and Deployment in ASP.NET 2.0
http://west-wind.com/presentations/AspNetCompilation/AspNetCompilation.asp

Please let me know if you need further information about this or how to
embed resource files and javascript files in your assembly too.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Thanks for the reply and explanation Walter.

I'm not using Windows Auth, so I've removed all the ASPX files and am just
left with all the external resources (CSS, JS, images etc).

If I used embedded resource files, would the output be cachable so that it
wouldn't have to be processed through the entire ASP.NET chain on every
request?

I'm cautious about changing something which is just a very simple static
file into something that could massively increase IIS overheads.

Let me know...

Many thanks,
Boris Y
 
W

Walter Wang [MSFT]

Hi Boris,

The embedded web resource will be cached. You can find more information
here (look for the "Perf" section):

#Nikhil Kothari's Weblog : Whats with System.Web.UI.WebResourceAttribute
http://www.nikhilk.net/WebResourceAttribute.aspx

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Thanks Walter, Nikhil's page was very helpful.

My next question is this:

All the examples of using WebResource seem to imply that you need to create
a separate Class Library project for the resources.

Currently I'm using the "Web Site Project" model.

Is there anything I can do from the UI or even from custom build flags etc
that would allow me to simply embed the resources I already have in the
project?

e.g. I just have a file in the root of the web project called "logo.gif".
And I want that to stay in the project but get compiled in as a resource
which I could then refer to as WebResource("MyWebProject.logo.gif").

Let me know...

Thanks,
Boris
 
W

Walter Wang [MSFT]

Hi Boris,

Thank you for your post!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Boris,

After done more research on this issue, it turns out this is not a easy
task.

For default web site mode, we cannot embed the resource as in class
library; the only way is to use App_GlobalResources or App_LocalResources
to embed the image or javascript in a resource file. You can use Reflector
to see the difference between the class library assembly and web site
assembly that is merged by Web Deployment Project. The class library that
embedded the image will have a direct image resource under the "Resources"
part. The web site assembly will have a resource file, which then has a
System.Drawing.Bitmap typed resource. This cause the
ClientScriptManager.GetWebResourceUrl fail to find this resource.

We could create our own HttpHandler just as WebResource.axd
(AssemblyResourceLoader) did to dynamically read from this resource, but it
will not be trivial, you could use Reflector to inspect the source code of
System.Web.Handlers.AssemblyResourceLoader.

Another option is to use Web Application Project, which is actually a class
library that can embed the resource. However, although this works to embed
the resource and use GetWebResourceUrl to get the dynamic url, based on my
test, this authoring mode seems doesn't work with aspnet_compiler.exe and
aspnet_merge.exe, which means you cannot remove the .ASPX files.

Let me know whether or not you need further information regarding this
issue. Thanks.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Walter,

Thanks for researching this further.

It sounds like the solution is way beyond the time I have available for this
now, but it also sounds like an interesting and useful project for when I do
have the time!

If you want an idea for .NET3.5, it would be very cool to be able to build
the entire web project (ASPX, code, images, css, all other resources) down to
a single DLL and web.config file. That would make deployment insanely simple
for us, and make sure the deployed site was untouchable by any developers
wanting to "quick fix" things on the production servers ;)

Thanks again,
Boris Y
 
W

Walter Wang [MSFT]

Hi Boris,

Thanks for your follow up and the suggestion. I agree that it is a great
idea.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Walter,

On a related issue, is it possible to use a default document when you have
removed all the ASPX files?

I have "Enable Default Content Page" checked in IIS configuration for the
web site, and I have the name of the file ("Login.aspx") as the only filename
in the listbox, but it doesn't seem to work when the physical file is
missing. I also have "Verify the file exists" unchecked in the ASP.NET dll
configuration.

Any clues?

Thanks,
Boris Y
 
W

Walter Wang [MSFT]

Hi Boris,

I believe the default document feature is implemented by IIS instead of
ASP.NET, which means it must be present to make it work.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

As a follow-up to this, I tried creating a zero byte login.aspx file instead
of my real login.aspx.

This works perfectly. IIS is happy and I now get Default Document support,
and it actually loads my real ASPX contents from the .compiled file instead
of the zero byte one on the disk.

Not a bad compromise :)

- Boris Y
 
W

Walter Wang [MSFT]

Hi Boris,

Good point, and yes that .ASPX is only a placeholder, the content inside it
is not important any more, :)

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top