HTML Extension for ASP.NET 2.0

G

guppywon

I am trying to map ASP.NET execution to the ".html" extension. And I am
encountering a strange error. I'm looking for help configuring my
".html" pages to execute as ".aspx" pages.

I have added the IIS file extension mapping, I have also added the
following to the Web.Config file:

<compilation>
<buildProviders>
<add extension=".html"
type="System.Web.Compilation.PageBuildProvider"
appliesTo="Web" />
</buildProviders>
</compilation>
<httpHandlers>
<add path="*.html"
verb="*"
type="System.Web.UI.PageHandlerFactory"
validate="True" />
</httpHandlers>

In my .html pages I receive a context error (example: "'Context' is not
a member of 'Default4'"), yet my page is wired up just like any other
normal aspx page, which do not receive any error.

Example file names: Default4.html, Default4.html.vb

Please help!

Thanks.
 
G

guppywon

Interesting. I am also using Beta2. How are you running your pages? Do
they have to be precompiled, or can I run them uncompiled as usual?
 
J

Juan T. Llibre

It looks like the "appliesTo" and "validate"
properties have been deprecated.

Try :

<compilation>
<buildProviders>
<add extension=".html"
type="System.Web.Compilation.PageBuildProvider"
/>
</buildProviders>
</compilation>
<httpHandlers>
<add path="*.html"
verb="*"
type="System.Web.UI.PageHandlerFactory"
/>
</httpHandlers>

And , of course, add the file type in the "configuration" option
for the application in the Internet Service Manager.

That's the way I set up my custom extension ".juan"

Check it out :

http://asp.net.do/test/version.juan



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
G

guppywon

The context error I am receiving is in Visual Studio 2005, and I am
trying to run the site using IIS. Do I need to do anything within
Visual Studio to support .html, or are my pages going to be
second-class citizens as with VS2003?
 
J

Juan T. Llibre

I don't understand your problem.

If your problem is that you want to create Html pages, go to the
File menu, then New, File, and select the HTML Page template.

Simply adding the "L" to the default .HTM filename lets you
build HTML pages and you'll have standard HTML objects
at your disposal which you can include in your HTML page.

Any HTML object which you insert will have a set of properties
which you can define in the Visual Studio Property box.

If you want to write JavaScript, you can do that, too,
although there's no additional help for that.

So, support for HTML files *is* there.

If your problem is that you want HTML files processed by
the ASP.NET engine, you *can* do that as I showed you.

I don't know of any way for Visual Studio to recognize custom
file extensions so that Intellisense, etc., work when a custom
extension is loaded ( Is that what you consider the problem to be ?).

You might workaround that by writing your code in an aspx file,
and renaming the file to the html extension when it's working.

If you setup the html extension per the instructions I sent you,
the pages *will* run, since your clients won't be using VS.NET
to run your pages, but their browsers.

Bottom line: VS.NET is behaving as it should, as I see it.

If you differ, please explain what you
would like VS.NET to do with HTML files.




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
B

Brock Allen

I don't have the rest of this thread, but I seem to recall that you said
you made the mappings in IIS for .html files to the ASP.NET ISAPI (make sure
it's the 2.0 version).

Just to see if everything's ok, I'd suggest starting from scratch. Make a
FileSystem project (that was you don't have IIS to worry about) and make
a simple .aspx and then switch it all over to .html and see if that works.
I'm thinking that you'll have to take these little steps to isolate the problem.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
G

guppywon

I was finally able to get it to work. I accidently misconfigured IIS,
and simply had to fix the mistake.
 

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

Top