How to make a page entirely in C#, no .aspx?

G

Guest

Hi,

It's a page behind file of the webpage.aspx. It's not a standalone page, it
willnot work without the .aspx.page.

cheers,

Jerome. M
 
B

Brock Allen

If you don't have an ASPX but a fully complete Page (and or implementation
of IHttpHandler) compiled in the ~/bin then you can do this via configuration.

<configuration>
<system.web>
<httpHandlers>
<add path="MyPage.aspx" verb="*" type="YourNamespace.YourClass, YourAssemblyWithOutTheDotDLL"
/>
</httpHandlers>
</system.web>
</configuration>
 
S

sarah

Thanks, that works well! Curiously, I have to use the .aspx extension in
the path. If I remove the .aspx from the path then I get a 404. Any idea
why?

Another problem: Although session state is enabled in web.config, and
ordinary .aspx pages are able to use session state, session state is off
in my Page-derived class. How do I turn on session state? I also tried the
<pages> element in web.config.

Ordinary .aspx pages can say EnableSessionState="true" in the <% @Page %>
directive. What is the equivalent in a Page-derived class? I see an
EnnableViewState property on Page, but no EnableSessionState.
 
B

Brock Allen

Thanks, that works well! Curiously, I have to use the .aspx extension
in the path. If I remove the .aspx from the path then I get a 404. Any
idea why?

IIS is pre-configured with certain extensions such as aspx, ashx, asax, asmx,
axd and others. So you'll have to use on of those or configure your own extension
(like .foo).

If you want no file extension at all, there are ways of accomplishing this,
but IIRC all very painful. Ian Griffiths has an entry on this:

http://www.interact-sw.co.uk/iangblog/2004/01/12/shinyurl

and there's a post on MSDN too:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp
Another problem: Although session state is enabled in web.config, and
ordinary .aspx pages are able to use session state, session state is
off in my Page-derived class. How do I turn on session state? I also
tried the <pages> element in web.config.

Your page needs to implement the IRequireSessionState interface -- it doesn't
have any methods to implement.
Ordinary .aspx pages can say EnableSessionState="true" in the <% @Page
%> directive. What is the equivalent in a Page-derived class? I see an
EnnableViewState property on Page, but no EnableSessionState.

This emits the IRequireSessionState implementation in the ASPX-generated
class.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top