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

  • Thread starter Thread starter sarah
  • Start date Start date
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
 
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>


-Brock
DevelopMentor
http://staff.develop.com/ballen
 
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.
 
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Back
Top