• Twitter
  • Facebook
  • Google+
  • Instagram
  • Youtube

Thursday, January 10, 2008

User Handler for Page Extension in Asp.Net

User Handler for Page Extension in Asp.Net
====================================

In some cases you need to display you website pages (.aspx) to another extension like (.cgi)

In that case, you need to use inbuilt handler of Asp.net

You can do it by this way :

Setup your web.config file
----------------------------------

Don't forget to add section those are marked in "bold" in below code.

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<appSettings>
<add key="PageSize" value="5" />
<add key="PageSize2" value="25"/>
<add key="MailFrom" value="admin@site.com"/>
<add key="SmtpServer" value="mail.netaxle.com"/>
<add key="SmtpServerUserName" value="smtp@servercom" />
<add key="SmtpServerPassword" value="buster43" />
<add key="FCKeditor:BasePath" value="~/FCKeditor/" />
<add key="DictionaryFolder" value="/SpellCheck/dic" />
</appSettings>
<connectionStrings>
<add name="ProjectNameDB" providerName="System.Data.SqlClient" connectionString="server=(local);database=DBName;UID=sa;PWD=pwd;"/>
</connectionStrings>
<dataConfiguration defaultDatabase="ProjectNameDB"/>
<system.web>
<sessionState timeout="30"></sessionState>

<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
<buildProviders>
<add extension=".cgi" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<pages enableEventValidation="false" validateRequest="false"></pages>
<authentication mode="Forms">
<forms loginUrl="admin/Login.cgi" timeout="240" name="ProjectName" defaultUrl="add/UserList.cgi"></forms>
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<!-- <customErrors defaultRedirect="errorpage.cgi" mode="On" >

</customErrors> -->
<customErrors mode="Off"/>


<httpHandlers>
<add path="*.cgi" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true" />
</httpHandlers>
</system.web>
<system.net>
<mailSettings>
<smtp>
<network host="mail.domain.com" userName="site@domain.com" password="buster43"/>
</smtp>
</mailSettings>
</system.net>
<location path="admin">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>

Setup in IIS for your Server
----------------------------------

1. Open you website properties from IIS

2. Goto Home Directory Tab and se the all criteria as per below image





3. Now click on 'Configuratino' from 'Home Directory' tab.

4. Then, Add new Extension of '.cgi' as per below image.




5. Select 'A redirection to url' radion button in 'Home Directory' tab.

6. Write this text into textbox, next to 'Redirect to' label , just like below image.




Redirection Text : *; /*.aspx; /$0.cgi$Q; /*.aspx; /$0.cgi;

Now, You can play with your website.
Feeling magic with .cgi extension instead of .aspx pages.

That's it !
Hope you will like it.

0 comments:

Contact

Get in touch with me


Adress/Street

12 Street West Victoria 1234 Australia

Phone number

+(12) 3456 789

Website

www.johnsmith.com